[DEV] manage the template function in parsing (not written in doc ...)

This commit is contained in:
Edouard DUPIN 2014-06-16 21:53:04 +02:00
parent aff1fdf89a
commit ea307ad3ac
3 changed files with 46 additions and 3 deletions

View File

@ -19,6 +19,15 @@ class Class(Node.Node):
if len(stack) < 2:
debug.error("Can not parse class : " + str(stack))
return
#check if it is a template class:
if stack[0] == "template":
debug.debug("find a template class: " + str(stack))
#remove template properties ==> not manage for now ...
stack = stack[stack.index("class"):]
# TODO : add the template properties back ...
if len(stack) < 2:
debug.error("Can not parse class 2 : " + str(stack))
return
Node.Node.__init__(self, 'class', stack[1], file, lineNumber, documentation)
self.subList = []
self.access = "private"

View File

@ -13,6 +13,7 @@ class Methode(Node.Node):
self.static = False
self.inline = False
self.const = False # the end of line cont methode is sont for the class ...
self.noexcept = False
# remove constructer inside declaration ...
if ':' in stack:
@ -24,6 +25,29 @@ class Methode(Node.Node):
break
stack = res
#check if it is a template class:
if stack[0] == "template":
debug.debug("find a template methode: " + str(stack))
#remove template properties ==> not manage for now ...
newStack = []
counter = 0
counterEnable = True
# start at the first '<'
for element in stack[1:]:
if counterEnable == True:
if element[0] == '<':
counter += 1;
elif element[0] == '>':
counter -= 1;
if counter == 0:
if counterEnable == True:
counterEnable = False
else:
newStack.append(element)
stack = newStack
# TODO : add the template properties back ...
debug.verbose("find a template methode: " + str(stack))
if stack[len(stack)-2] == '=' \
and stack[len(stack)-1] == '0':
stack = stack[:len(stack)-2]
@ -38,6 +62,9 @@ class Methode(Node.Node):
if stack[0] == 'inline':
self.inline = True
stack = stack[1:]
if stack[len(stack)-1] == 'noexcept':
self.noexcept = True
stack = stack[:len(stack)-1]
if stack[len(stack)-1] == 'const':
self.const = True
stack = stack[:len(stack)-1]

View File

@ -24,6 +24,7 @@ import monkNode as Node
tokens = [
'NUMBER',
'TEMPLATE',
'NAME',
'OPEN_PAREN',
'CLOSE_PAREN',
@ -59,7 +60,8 @@ tokens = [
]
t_ignore = " \r.?@\f"
t_NUMBER = r'[0-9][0-9XxA-Fa-f]*'
t_TEMPLATE = r'template'
t_NUMBER = r'[0-9][0-9XxA-Fa-f]*L?'
t_NAME = r'[<>A-Za-z_~][A-Za-z0-9_]*'
t_OPEN_PAREN = r'\('
t_CLOSE_PAREN = r'\)'
@ -237,7 +239,7 @@ class parse_file():
# Strip out template declarations
# TODO : What is the real need ???
headerFileStr = re.sub("template[\t ]*<[^>]*>", "", headerFileStr)
#headerFileStr = re.sub("template[\t ]*<[^>]*>", "", headerFileStr)
# remove all needed \r unneeded ==> this simplify next resExp ...
headerFileStr = re.sub("\r", "\r\n", headerFileStr)
headerFileStr = re.sub("\r\n\n", "\r\n", headerFileStr)
@ -561,6 +563,11 @@ def is_a_function(stack) :
#can end with 2 possibilities : ')', 'const' or ')'
if stack[len(stack)-1] == ')' \
or ( stack[len(stack)-2] == ')' \
and stack[len(stack)-1] == 'const'):
and stack[len(stack)-1] == 'const')\
or ( stack[len(stack)-2] == ')' \
and stack[len(stack)-1] == 'noexcept')\
or ( stack[len(stack)-3] == ')' \
and stack[len(stack)-2] == 'const' \
and stack[len(stack)-1] == 'noexcept'):
return True
return False