From e27896b134a1fc8ccd6e840661f171302f938eb4 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 3 Oct 2017 15:19:07 +0200 Subject: [PATCH] [DEV] set it work again and basic parse of merkdown --- codeHL/codeHL.py | 3 +- codeMarkDown/MD_Code.py | 51 ++++++++++++++++ codeMarkDown/MD_Image.py | 19 ++++++ codeMarkDown/MD_IndentAndDot.py | 60 ++++++++++++++++++ codeMarkDown/MD_Link.py | 84 ++++++++++++++++++++++++++ codeMarkDown/MD_Specification.py | 17 ++++++ codeMarkDown/MD_Table.py | 42 +++++++++++++ codeMarkDown/MD_Text.py | 49 +++++++++++++++ codeMarkDown/MD_Title.py | 73 ++++++++++++++++++++++ codeMarkDown/MD_comment.py | 23 +++++++ codeMarkDown/MD_lineReturn.py | 30 +++++++++ codeMarkDown/codeMarkDown.py | 61 +++++++++++++++++++ monkArg.py | 4 +- monkEnum.py | 22 +++++-- monkHtml.py | 15 ++++- monkMethode.py | 6 +- monkModule.py | 9 ++- monkParse.py | 47 +++++++------- monkType.py | 10 +-- ply/example/GardenSnake/GardenSnake.py | 2 +- 20 files changed, 583 insertions(+), 44 deletions(-) create mode 100644 codeMarkDown/MD_Code.py create mode 100644 codeMarkDown/MD_Image.py create mode 100644 codeMarkDown/MD_IndentAndDot.py create mode 100644 codeMarkDown/MD_Link.py create mode 100644 codeMarkDown/MD_Specification.py create mode 100644 codeMarkDown/MD_Table.py create mode 100644 codeMarkDown/MD_Text.py create mode 100644 codeMarkDown/MD_Title.py create mode 100644 codeMarkDown/MD_comment.py create mode 100644 codeMarkDown/MD_lineReturn.py create mode 100644 codeMarkDown/codeMarkDown.py diff --git a/codeHL/codeHL.py b/codeHL/codeHL.py index c36f8ae..773c0d0 100644 --- a/codeHL/codeHL.py +++ b/codeHL/codeHL.py @@ -12,7 +12,8 @@ import codeHLshell def transcode(type, value): - if type == "c++": + if type == "c++" \ + or type == "cpp": value = codeHLcpp.transcode(value) elif type == "java": value = codeHLJava.transcode(value) diff --git a/codeMarkDown/MD_Code.py b/codeMarkDown/MD_Code.py new file mode 100644 index 0000000..7c9556a --- /dev/null +++ b/codeMarkDown/MD_Code.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import codeHL +import re + + +## +## @brief Transcode balise : +## [code language=cpp] +## int main(void) { +## return 0; +## } +## [/code] +## @param[in] value String to transform. +## @return Transformed string. +## +def transcode(value): + #value = re.sub(r'\[code(( |\t|\n|\r)+style=(.*))?\](.*?)\[/code\]', + """ + value = re.sub(r'```(( |\t|\n|\r){\.(.*?))?\}(.*?)\```', + replace_code, #r'
\4
', + value, + flags=re.DOTALL) + """ + value = re.sub(r'```(( |\t|\n|\r)*(\{\.(.*?)\}))?(.*?)\```', + replace_code, #r'
\4
', + value, + flags=re.DOTALL) + + # TODO : remove the basic indentation of the element (to have a better display in the text tutorial ... + return value + +def transcode_part2(value): + value = value.replace(":CODE:UNDER:SCORE:", "_") + value = value.replace(":CODE:STAR:", "*") + return value + + +def replace_code(match): + if match.group() == "": + return "" + #debug.info("plop: " + str(match.groups())) + #debug.info("code format: " + str(match.groups()[3])) + value = codeHL.transcode(match.groups()[3], match.groups()[4]) + #value = value.replace("\n", "
") + value = value.replace("_", ":CODE:UNDER:SCORE:") + value = value.replace("*", ":CODE:STAR:") + return '
' + str(value) + '
' + diff --git a/codeMarkDown/MD_Image.py b/codeMarkDown/MD_Image.py new file mode 100644 index 0000000..443eaee --- /dev/null +++ b/codeMarkDown/MD_Image.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import re + + +## +## @brief Transcode balise: +## [img w=125 h=45]dossier/image.jpg[/img] +## [img w=125 h=45]http://plop.com/dossier/image.png[/img] +## @param[in] value String to transform. +## @return Transformed string. +## +def transcode(value): + + return value + + diff --git a/codeMarkDown/MD_IndentAndDot.py b/codeMarkDown/MD_IndentAndDot.py new file mode 100644 index 0000000..e02f873 --- /dev/null +++ b/codeMarkDown/MD_IndentAndDot.py @@ -0,0 +1,60 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import re + + +## +## @brief Transcode +## commencez les lignes par: +## * +## * +## +## + +## + +## +## resultat: +## +## - +## - +## - +## +## commencez les lignes par: +## - +## - +## +## resultat: +## +## 1. +## 2. +## 3. +## +## @param[in] value String to transform. +## @return Transformed string. +## +def transcode(value): + value = re.sub(r'\n(( - )|( * )|( # ))', + r'\n:INDENT:[STAR]', + value) + p = re.compile('((\:INDENT\:(.*?)\n)*)', + flags=re.DOTALL) + value = p.sub(replace_wiki_identation, + value) + value = re.sub(r'\[STAR\](.*?)\n', + r'
  • \1
  • ', + value, + flags=re.DOTALL) + return value + + +def replace_wiki_identation(match): + if match.group() == "": + return "" + #debug.verbose("plop: " + str(match.group())) + value = "" + return transcode(value) diff --git a/codeMarkDown/MD_Link.py b/codeMarkDown/MD_Link.py new file mode 100644 index 0000000..f7116ca --- /dev/null +++ b/codeMarkDown/MD_Link.py @@ -0,0 +1,84 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import re + + +## +## @brief Transcode: +## [http://votre_site.con] => http://votre_site.con +## [http://votre_site.con | text displayed] => text displayed +## [http://votre_site.con text displayed] => text displayed. +## +## @param[in] value String to transform. +## @return Transformed string. +## +def transcode(value): + + + # named link : [[http://plop.html | link name]] + value = re.sub(r'\[\[http://(.*?) \| (.*?)\]\]', + r'\2', + value) + + # direct link : [[http://plop.html]] + value = re.sub(r'\[\[http://(.*?)\]\]', + r'http://\1', + value) + + # direct lib link : [lib[libname]] + value = re.sub(r'\[lib\[(.*?) \| (.*?)\]\]', + r'\2', + value) + + value = re.sub(r'\[doc\[(.*?) \| (.*?)\]\]', + r'\2', + value) + + value = re.sub(r'\[tutorial\[(.*?) \| (.*?)\]\]', + r'\2', + value) + + value = re.sub(r'\[(lib|class|methode)\[(.*?)\]\]', + replace_link_class, + value) + + """ + p = re.compile('\[\[(.*?)(|(.*?))\]\])', + flags=re.DOTALL) + value = p.sub(replace_link, + value) + """ + return value + +""" +def replace_link(match): + if match.group() == "": + return "" + #debug.verbose("plop: " + str(match.group())) + value = "" + return transcode(value) +""" + +def replace_link_class(match): + if match.group() == "": + return "" + #debug.info("plop: " + str(match.group())) + if match.groups()[0] == 'class': + className = match.groups()[1] + value = re.sub(':', '_', className) + return '' + className + '' + elif match.groups()[0] == 'lib': + return match.groups()[1] + elif match.groups()[0] == 'methode': + return match.groups()[1] + else: + return match.groups()[1] + + + diff --git a/codeMarkDown/MD_Specification.py b/codeMarkDown/MD_Specification.py new file mode 100644 index 0000000..c487373 --- /dev/null +++ b/codeMarkDown/MD_Specification.py @@ -0,0 +1,17 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import re + + +## +## @brief Transcode thales specification ... +## @param[in] value String to transform. +## @return Transformed string. +## +def transcode(value): + + return value + + diff --git a/codeMarkDown/MD_Table.py b/codeMarkDown/MD_Table.py new file mode 100644 index 0000000..c4a629d --- /dev/null +++ b/codeMarkDown/MD_Table.py @@ -0,0 +1,42 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import re + + +## +## @brief Transcode table: +## { | tableau_type_1 +## | [b]colone 1[/b] +## ligne 1 +## | colone 2 ligne 1 +## |--- +## | colone 1 ligne 1 +## | colone 2 ligne 2 +## |} +## Avec autant de ligne et de colone que vous voullez.. +## Il est possible de faire des retour a la ligne dans une case du tableau... +## En bref sa tend a marcher comme sur un Wiki... +## +## result: +## +-------------------------------------+ +## | colone 1 | +## +------------------+------------------+ +## | ligne 1 | colone 2 ligne 1 | +## +------------------+------------------+ +## | colone 1 ligne 1 | colone 2 ligne 2 | +## +------------------+------------------+ +## +## TODO : Create simple table like : +## | colone 1 || +## | ligne 1 | colone 2 ligne 1 | +## | colone 1 ligne 1 | colone 2 ligne 2| +## @param[in] value String to transform. +## @return Transformed string. +## +def transcode(value): + + return value + + diff --git a/codeMarkDown/MD_Text.py b/codeMarkDown/MD_Text.py new file mode 100644 index 0000000..ba08013 --- /dev/null +++ b/codeMarkDown/MD_Text.py @@ -0,0 +1,49 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import re + + +## +## @brief Transcode . +## [b]texte ici[/b] +## [i]texte ici[/i] +## [u]texte ici[/u] +## [strike]texte ici[/strike] +## [color=olive]texte ici[/color] +## [color=#456FF33F]texte ici[/color] +## Left : [left]texte ici[/left] +## Center : [center]texte ici[/center] +## Right : [right]texte ici[/right] +## [size=22]sdfgsdfgsdgsfd[/size] +## [cadre]mettre les code ici[/cadre] +## @param[in] string String to transform. +## @return Transformed string. +## +def transcode(value): + + value = re.sub(r'\*\*(.*?)\*\*', + r'\1', + value, + flags=re.DOTALL) + value = re.sub(r'__(.*?)__', + r'\1', + value, + flags=re.DOTALL) + + value = re.sub(r'\*(.*?)\*', + r'\1', + value, + flags=re.DOTALL) + value = re.sub(r'_(.*?)_', + r'\1', + value, + flags=re.DOTALL) + + value = re.sub(r'____(.*?)\n', + r'
    ', + value, + flags=re.DOTALL) + + return value diff --git a/codeMarkDown/MD_Title.py b/codeMarkDown/MD_Title.py new file mode 100644 index 0000000..8830d41 --- /dev/null +++ b/codeMarkDown/MD_Title.py @@ -0,0 +1,73 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import re + + +## +## @brief Transcode . +## =?=Page Title=?= +## ==Title 1== +## ===Title 2=== +## ====Title 3==== +## =====Title 4===== +## ======Title 5====== +## @param[in] value String to transform. +## @return Transformed string. +## +def transcode(value): + value = "\n" + value + + + value = re.sub(r'@tableofcontents', + r'', + value) + + value = re.sub(r'\n(.*?)(( |\t)*\{.*\})*\n====*', + r'\n

    \1

    ', + value) + value = re.sub(r'\n(.*?)(( |\t)*\{.*\})*\n---*', + r'\n

    \1

    ', + value) + + value = re.sub(r'\n###### (.*?)(( |\t)*\{.*\})* ######', + r'\n
    \1
    ', + value) + value = re.sub(r'\n###### (.*?)(( |\t)*\{.*\})*', + r'\n
    \1
    ', + value) + + value = re.sub(r'\n##### (.*?)(( |\t)*\{.*\})* #####', + r'\n
    \1
    ', + value) + value = re.sub(r'\n##### (.*?)(( |\t)*\{.*\})*', + r'\n
    \1
    ', + value) + + value = re.sub(r'\n#### (.*?)(( |\t)*\{.*\})* ####', + r'\n

    \1

    ', + value) + value = re.sub(r'\n#### (.*?)(( |\t)*\{.*\})*', + r'\n

    \1

    ', + value) + + value = re.sub(r'\n### (.*?)(( |\t)*\{.*\})* ###', + r'\n

    \1

    ', + value) + value = re.sub(r'\n### (.*?)(( |\t)*\{.*\})*', + r'\n

    \1

    ', + value) + + value = re.sub(r'\n## (.*?)(( |\t)*\{.*\})* ##', + r'\n

    \1

    ', + value) + value = re.sub(r'\n## (.*?)(( |\t)*\{.*\})*', + r'\n

    \1

    ', + value) + + value = value[1:] + + return value + + diff --git a/codeMarkDown/MD_comment.py b/codeMarkDown/MD_comment.py new file mode 100644 index 0000000..edad0dd --- /dev/null +++ b/codeMarkDown/MD_comment.py @@ -0,0 +1,23 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import re + +_comment_code = "[comment]:" +## +## @brief Transcode balise: +## line start with [comment]: +## @param[in] value String to transform. +## @return Transformed string. +## +def transcode(value): + out = ""; + for elem in value.split("\n"): + if len(elem) >= len(_comment_code) \ + and elem[:len(_comment_code)] == _comment_code: + continue + out += elem + "\n" + return out + + diff --git a/codeMarkDown/MD_lineReturn.py b/codeMarkDown/MD_lineReturn.py new file mode 100644 index 0000000..9c372f3 --- /dev/null +++ b/codeMarkDown/MD_lineReturn.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import re + + +## +## @brief Transcode balise: +## \n\n ==>
    +## @param[in] value String to transform. +## @return Transformed string. +## +def transcode(value): + + value = re.sub(r'\r\n', + r'\n', + value) + + value = re.sub(r'\n\n', + r'
    ', + value) + + value = re.sub(r'
    ', + r'
    \n', + value) + + return value + + diff --git a/codeMarkDown/codeMarkDown.py b/codeMarkDown/codeMarkDown.py new file mode 100644 index 0000000..a13b611 --- /dev/null +++ b/codeMarkDown/codeMarkDown.py @@ -0,0 +1,61 @@ +#!/usr/bin/python +import monkDebug as debug +import sys +import monkTools +import re +""" +import BB_Link +import BB_Image +import BB_Table + +import BB_Specification +""" +import MD_Text +import MD_IndentAndDot +import MD_Title +import MD_comment +import MD_lineReturn +import MD_Code +## +## @brief Transcode input data in the corect format. +## @param[in] string String to transform. +## @return Transformed string. +## +def transcode(value): + # remove html property + value = re.sub(r'&', r'&', value) + value = re.sub(r'<', r'<', value) + value = re.sub(r'>', r'>', value) + value = re.sub(r'\r\n', r'\n', value) + value = re.sub(r'\n\r', r'\n', value) + value = re.sub(r'\r', r'\n', value) + value = MD_comment.transcode(value) + value = MD_Title.transcode(value) + value = MD_IndentAndDot.transcode(value) + value = MD_Code.transcode(value) + value = MD_lineReturn.transcode(value) + value = MD_Text.transcode(value) + """ + value = BB_Text.transcode(value) + value = BB_Link.transcode(value) + value = BB_Image.transcode(value) + value = BB_Table.transcode(value) + value = BB_Specification.transcode(value) + """ + value = MD_Code.transcode_part2(value) + return value + +## +## @brief transcode a BBcode file in a html file +## @return True if the file is transformed +## +def transcode_file(inputFileName, outputFileName): + inData = monkTools.file_read_data(inputFileName) + if inData == "": + return False + outData = transcode(inData) + debug.warning(" out: " + outputFileName) + monkTools.file_write_data(outputFileName, outData) + return True + + diff --git a/monkArg.py b/monkArg.py index 38c0606..5f5361f 100644 --- a/monkArg.py +++ b/monkArg.py @@ -246,5 +246,5 @@ class MonkArg: for element in self.list_properties : listOfPropertiesArg += element.get_porperties() print(" " + sys.argv[0] + listOfPropertiesArg + " ...") - for element in self.list_properties : - element.display() \ No newline at end of file + for element in self.m_list_properties : + element.display() diff --git a/monkEnum.py b/monkEnum.py index e0ff94e..0c75eb3 100644 --- a/monkEnum.py +++ b/monkEnum.py @@ -10,22 +10,34 @@ class Enum(Node.Node): debug.error("Can not parse enum : " + str(stack)) return self.typedef = False - if stack[0] == 'typedef': + if len(stack) > 0 \ + and stack[0] == 'typedef': self.typedef = True stack[1:] - if len(stack) == 0: + if len(stack) > 0 \ + and stack[0] == 'enum': + stack[1:] + else: debug.error("Can not parse enum : " + str(stack)) return - if len(stack) == 1: - localEnumName = "" - else: + self.is_class = False + if len(stack) > 0 \ + and stack[0] == 'class': + self.is_class = True + stack[1:] + if len(stack) >= 1: localEnumName = stack[1] + else: + debug.error("Can not parse enum : " + str(stack)) + return Node.Node.__init__(self, 'enum', localEnumName, file, lineNumber, documentation) self.list_element = [] def to_str(self) : + if self.is_class == True: + return "enum class " + self.name + " { ... };" return "enum " + self.name + " { ... };" def enum_append(self, stack): diff --git a/monkHtml.py b/monkHtml.py index 612699e..effce95 100644 --- a/monkHtml.py +++ b/monkHtml.py @@ -6,6 +6,7 @@ import monkTools as tools import os import re import codeBB +import codeMarkDown import collections import monkModule as module import monkNode as node @@ -765,8 +766,11 @@ def generate(my_lutin_doc, outFolder) : localHeader += "\n" outData += codeBB.transcode(localHeader) #debug.info(localHeader) - outData += codeBB.transcode(inData) - outData += generic_footer + if docInputName[-2:] == "bb": + outData += codeBB.transcode(inData) + elif docInputName[-2:] == "md": + outData += codeMarkDown.transcode(inData) + outData += genericFooter tools.file_write_data(outputFileName, outData) for docInputName,outpath in my_lutin_doc.list_doc_file : @@ -777,7 +781,12 @@ def generate(my_lutin_doc, outFolder) : inData = tools.file_read_data(docInputName) if inData == "": continue - outData = generic_header + codeBB.transcode(inData) + generic_footer + outData = generic_header + if docInputName[-2:] == "bb": + outData += codeBB.transcode(inData) + elif docInputName[-2:] == "md": + outData += codeMarkDown.transcode(inData) + outData += generic_footer tools.file_write_data(outputFileName, outData) diff --git a/monkMethode.py b/monkMethode.py index df3102b..b9f5637 100644 --- a/monkMethode.py +++ b/monkMethode.py @@ -15,6 +15,7 @@ class Methode(Node.Node): self.inline = False self.const = False # the end of line cont methode is sont for the class ... self.noexcept = False + self.override = False self.delete = False # remove constructer inside declaration ... @@ -61,7 +62,10 @@ class Methode(Node.Node): stack = stack[:len(stack)-2] self.delete = True - while stack[0] in ['virtual', 'static', 'inline']: + while len(stack) > 0\ + and ( stack[0] == 'virtual'\ + or stack[0] == 'static'\ + or stack[0] == 'inline'):: if stack[0] == 'virtual': self.virtual = True stack = stack[1:] diff --git a/monkModule.py b/monkModule.py index 23496e7..2b9d066 100644 --- a/monkModule.py +++ b/monkModule.py @@ -112,7 +112,7 @@ class Module: debug.info('Parse documantation code : ' + self.name) if self.path_parsing != "": for root, dirnames, filenames in os.walk(self.path_parsing): - tmpList = fnmatch.filter(filenames, "*.h") + tmpList = fnmatch.filter(filenames, "*.hpp") # Import the module : for filename in tmpList: fileCompleteName = os.path.join(root, filename) @@ -127,16 +127,21 @@ class Module: #self.structure_lib.debug_display() if self.path_global_doc != "": for root, dirnames, filenames in os.walk(self.path_global_doc): - tmpList = fnmatch.filter(filenames, "*.bb") + tmpList = fnmatch.filter(filenames, "*.md") # Import the module : for filename in tmpList: fileCompleteName = os.path.join(root, filename) tutorialPath = os.path.join(self.path_global_doc, "tutorial/") pathBase = fileCompleteName[len(self.path_global_doc):len(fileCompleteName)-3] + while len(pathBase) > 0 \ + and pathBase[0] == '/': + pathBase = pathBase[1:] debug.verbose(" Find a doc file : fileCompleteName='" + fileCompleteName + "'") if fileCompleteName[:len(tutorialPath)] == tutorialPath: + debug.warning("add_tutorial_doc : '" + fileCompleteName + "' ==> '" + pathBase + "'") self.add_tutorial_doc(fileCompleteName, pathBase) else: + debug.warning("add_file_doc : '" + fileCompleteName + "' ==> '" + pathBase + "'") self.add_file_doc(fileCompleteName, pathBase) ## diff --git a/monkParse.py b/monkParse.py index 47127a8..90d985d 100644 --- a/monkParse.py +++ b/monkParse.py @@ -2,11 +2,13 @@ import os import sys import re +import copy import monkTools as tools sys.path.append(tools.get_current_path(__file__) + "/ply/ply/") sys.path.append(tools.get_current_path(__file__) + "/codeBB/") +sys.path.append(tools.get_current_path(__file__) + "/codeMarkDown/") sys.path.append(tools.get_current_path(__file__) + "/codeHL/") import lex @@ -84,7 +86,7 @@ t_EXCLAMATION = r'!' def t_PRECOMP(t): r'\#.*?\n' t.value = re.sub(r'\#\#multiline\#\#', "\\\n", t.value) - t.lexer.lineno += len(filter(lambda a: a=="\n", t.value)) + t.lexer.lineno += len(list(filter(lambda a: a=="\n", t.value))) return t def t_COMMENT_SINGLELINE_DOC_PREVIOUS(t): r'//(/|!)<.*?\n' @@ -129,7 +131,8 @@ t_STRING_LITERAL = r'"([^"\\]|\\.)*"' #Found at http://ostermiller.org/findcomment.html def t_COMMENT_MULTILINE_DOC(t): r'/\*(\*|!)(\n|.)*?\*/' - t.lexer.lineno += len(filter(lambda a: a=="\n", t.value)) + filter_result = list(filter(lambda a: a=="\n", t.value)) + t.lexer.lineno += len(filter_result) t.value = re.sub("( |\t)*\*", "", t.value[3:-2]) while t.value[0] == '\n': if len(t.value) <= 2: @@ -164,7 +167,7 @@ def t_COMMENT_MULTILINE_DOC(t): return t def t_COMMENT_MULTILINE(t): r'/\*(\n|.)*?\*/' - t.lexer.lineno += len(filter(lambda a: a=="\n", t.value)) + t.lexer.lineno += len(list(filter(lambda a: a=="\n", t.value))) def t_NEWLINE(t): r'\n+' t.lexer.lineno += len(t.value) @@ -607,31 +610,27 @@ class parse_file(): def is_a_function(stack) : # in a function we need to have functionName + ( + ) - if len(stack) < 3: + tmp = copy.deepcopy(stack); + while len(tmp) > 0\ + and ( tmp[-1] == 'const'\ + or tmp[-1] == 'noexcept'\ + or tmp[-1] == 'override'\ + or tmp[-1] == 'volatile'): + tmp = tmp[:-1] + if len(tmp) < 3: return False - if ':' in stack: + if ':' in tmp: res = [] - for element in stack: + for element in tmp: if element != ':': res.append(element) else: break - stack = res - if stack[len(stack)-2] == '=' \ - and stack[len(stack)-1] == '0': - stack = stack[:len(stack)-2] - if stack[len(stack)-2] == '=' \ - and stack[len(stack)-1] == 'delete': - stack = stack[:len(stack)-2] - # find ')' element : - id = len(stack)-1 - while id >= 0: - if stack[id] == ')': - break; - id -= 1 - if id >= 0: - for elem in stack[id+1:]: - if elem not in ['const', 'noexcept', 'override']: - return False + tmp = res + if tmp[-2] == '=' \ + and tmp[-1] == '0': + tmp = tmp[:-2] + #can end with 2 possibilities : ')', 'const' or ')' + if tmp[-1] == ')': return True - return False \ No newline at end of file + return False diff --git a/monkType.py b/monkType.py index 3aff20c..4641392 100644 --- a/monkType.py +++ b/monkType.py @@ -14,15 +14,15 @@ global_basic_type = ['void', 'bool', \ 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'uint128_t', \ 'T', 'CLASS_TYPE'] global_class_link = { - "std::string" : "http://www.cplusplus.com/reference/string/string/", + "etk::String" : "http://www.cplusplus.com/reference/string/string/", "std::u16string" : "http://www.cplusplus.com/reference/string/u16string/", "std11::u16string" : "http://www.cplusplus.com/reference/string/u16string/", - "std::u32string" : "http://www.cplusplus.com/reference/string/u32string/", + "etk::UString" : "http://www.cplusplus.com/reference/string/u32string/", "std11::u32string" : "http://www.cplusplus.com/reference/string/u32string/", "std::wstring" : "http://www.cplusplus.com/reference/string/wstring/", - "std::vector" : "http://www.cplusplus.com/reference/vector/vector/", + "etk::Vector" : "http://www.cplusplus.com/reference/vector/vector/", "std::list" : "http://www.cplusplus.com/reference/list/list/", - "std::pair" : "http://www.cplusplus.com/reference/utility/pair/", + "etk::Pair" : "http://www.cplusplus.com/reference/utility/pair/", "std::tuple" : "http://www.cplusplus.com/reference/tuple/tuple/", "std::shared_ptr" : "http://www.cplusplus.com/reference/memory/shared_ptr/", @@ -34,7 +34,7 @@ global_class_link = { "std::enable_shared_from_this" : "http://www.cplusplus.com/reference/memory/enable_shared_from_this/", "std11::enable_shared_from_this" : "http://www.cplusplus.com/reference/memory/enable_shared_from_this/", - "std::mutex" : "http://www.cplusplus.com/reference/mutex/mutex/", + "ethread::Mutex" : "http://www.cplusplus.com/reference/mutex/mutex/", "std11::mutex": "http://www.cplusplus.com/reference/mutex/mutex/", "std::unique_lock" : "http://www.cplusplus.com/reference/mutex/unique_lock/", diff --git a/ply/example/GardenSnake/GardenSnake.py b/ply/example/GardenSnake/GardenSnake.py index 2a7f45e..e3acfb7 100644 --- a/ply/example/GardenSnake/GardenSnake.py +++ b/ply/example/GardenSnake/GardenSnake.py @@ -648,7 +648,7 @@ from compiler import misc, syntax, pycodegen class GardenSnakeCompiler(object): def __init__(self): self.parser = GardenSnakeParser() - def compile(self, code, filename=""): + def compile(self, code, filename=""): tree = self.parser.parse(code) #print tree misc.set_filename(filename, tree)