fix a few bugs parsing functions
This commit is contained in:
parent
e7482b88f6
commit
cb8402018f
@ -49,11 +49,11 @@ class Parser(object):
|
|||||||
|
|
||||||
def p_function(self, p):
|
def p_function(self, p):
|
||||||
'function : type ID LPAREN RPAREN LCURLY function_items RCURLY'
|
'function : type ID LPAREN RPAREN LCURLY function_items RCURLY'
|
||||||
p[0] = FunctionNode(p[2], p[1], None, p[6])
|
p[0] = FunctionNode(p[2], p[1], None, p[6].children)
|
||||||
|
|
||||||
def p_function_items(self, p):
|
def p_function_items(self, p):
|
||||||
'function_items : function_item function_items'
|
'function_items : function_item function_items'
|
||||||
p[0] = Node([p[1] + p[2].children])
|
p[0] = Node([p[1]] + p[2].children)
|
||||||
|
|
||||||
def p_function_items_empty(self, p):
|
def p_function_items_empty(self, p):
|
||||||
'function_items : empty'
|
'function_items : empty'
|
||||||
|
@ -27,7 +27,8 @@ class UnitNode(Node):
|
|||||||
Node.__init__(self, children)
|
Node.__init__(self, children)
|
||||||
|
|
||||||
class FunctionNode(Node):
|
class FunctionNode(Node):
|
||||||
def __init__(self, name, ret_type, children=None):
|
def __init__(self, name, ret_type, param_list, children=None):
|
||||||
Node.__init__(self, children)
|
Node.__init__(self, children)
|
||||||
self.name = name
|
self.name = name
|
||||||
self.ret_type = ret_type
|
self.ret_type = ret_type
|
||||||
|
self.param_list = param_list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user