remove function_items, just use unit_items
This commit is contained in:
parent
3aca59f4f3
commit
5d3495a542
@ -27,16 +27,16 @@ class Parser(object):
|
|||||||
'unit_items : empty'
|
'unit_items : empty'
|
||||||
p[0] = p[1]
|
p[0] = p[1]
|
||||||
|
|
||||||
def p_unit_item_c_stmt(self, p):
|
def p_unit_item_stmt(self, p):
|
||||||
'unit_item : c_expr SEMICOLON'
|
'unit_item : stmt'
|
||||||
p[0] = p[1]
|
p[0] = p[1]
|
||||||
|
|
||||||
def p_unit_item_function(self, p):
|
def p_unit_item_function(self, p):
|
||||||
'unit_item : function'
|
'unit_item : function'
|
||||||
p[0] = p[1]
|
p[0] = p[1]
|
||||||
|
|
||||||
def p_statement(self, p):
|
def p_stmt(self, p):
|
||||||
'statement : expr SEMICOLON'
|
'stmt : expr SEMICOLON'
|
||||||
p[0] = StatementNode([p[1]])
|
p[0] = StatementNode([p[1]])
|
||||||
|
|
||||||
def p_expr(self, p):
|
def p_expr(self, p):
|
||||||
@ -48,21 +48,9 @@ class Parser(object):
|
|||||||
p[0] = CExprNode(p[3])
|
p[0] = CExprNode(p[3])
|
||||||
|
|
||||||
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 unit_items RCURLY'
|
||||||
p[0] = FunctionNode(p[2], p[1], None, p[6].children)
|
p[0] = FunctionNode(p[2], p[1], None, p[6].children)
|
||||||
|
|
||||||
def p_function_items(self, p):
|
|
||||||
'function_items : function_item function_items'
|
|
||||||
p[0] = Node([p[1]] + p[2].children)
|
|
||||||
|
|
||||||
def p_function_items_empty(self, p):
|
|
||||||
'function_items : empty'
|
|
||||||
p[0] = p[1]
|
|
||||||
|
|
||||||
def p_function_item_stmt(self, p):
|
|
||||||
'function_item : statement'
|
|
||||||
p[0] = p[1]
|
|
||||||
|
|
||||||
def p_type(self, p):
|
def p_type(self, p):
|
||||||
'''type : CHAR
|
'''type : CHAR
|
||||||
| SHORT
|
| SHORT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user