'is_invalid' : 'IS_INVALID',
'else' : 'ELSE',
'return' : 'RETURN',
- 'THIS' : 'THIS',
- 'CHIP' : 'CHIP',
'void' : 'VOID',
'new' : 'NEW',
'OOD' : 'OOD',
"decl : type ident pairs SEMI"
p[0] = ast.ObjDeclAST(self, p[1], p[2], p[3])
+ # Function definition and declaration
def p_decl__func_decl(self, p):
- """decl : void ident '(' params ')' pairs SEMI
+ "decl : func_decl"
+ p[0] = p[1]
+
+ def p_func_decl__0(self, p):
+ """func_decl : void ident '(' params ')' pairs SEMI
| type ident '(' params ')' pairs SEMI"""
p[0] = ast.FuncDeclAST(self, p[1], p[2], p[4], p[6], None)
def p_decl__func_def(self, p):
- """decl : void ident '(' params ')' pairs statements
- | type ident '(' params ')' pairs statements"""
+ "decl : func_def"
+ p[0] = p[1]
+
+ def p_func_def__0(self, p):
+ """func_def : void ident '(' params ')' pairs statements
+ | type ident '(' params ')' pairs statements"""
p[0] = ast.FuncDeclAST(self, p[1], p[2], p[4], p[6], p[7])
# Type fields
"type_member : type_or_void ident '(' types ')' pairs SEMI"
p[0] = ast.TypeFieldMethodAST(self, p[1], p[2], p[4], p[6])
+ def p_type_method__1(self, p):
+ "type_member : type_or_void ident '(' params ')' pairs statements"
+ p[0] = ast.FuncDeclAST(self, p[1], p[2], p[4], p[6], p[7])
+
def p_type_member__1(self, p):
"type_member : type_or_void ident pairs SEMI"
p[0] = ast.TypeFieldMemberAST(self, p[1], p[2], p[3], None)
"aexpr : OOD"
p[0] = ast.OodAST(self)
- # globally access a local chip component and call a method
- def p_expr__local_chip_method(self, p):
- "aexpr : THIS DOT var '[' expr ']' DOT var DOT ident '(' exprs ')'"
- p[0] = ast.LocalChipMethodAST(self, p[3], p[5], p[8], p[10], p[12])
-
- # globally access a local chip component and access a data member
- def p_expr__local_chip_member(self, p):
- "aexpr : THIS DOT var '[' expr ']' DOT var DOT field"
- p[0] = ast.LocalChipMemberAST(self, p[3], p[5], p[8], p[10])
-
- # globally access a specified chip component and call a method
- def p_expr__specified_chip_method(self, p):
- "aexpr : CHIP '[' expr ']' DOT var '[' expr ']' DOT var DOT ident '(' exprs ')'"
- p[0] = ast.SpecifiedChipMethodAST(self, p[3], p[6], p[8], p[11], p[13],
- p[15])
-
- # globally access a specified chip component and access a data member
- def p_expr__specified_chip_member(self, p):
- "aexpr : CHIP '[' expr ']' DOT var '[' expr ']' DOT var DOT field"
- p[0] = ast.SpecifiedChipMemberAST(self, p[3], p[6], p[8], p[11], p[13])
-
def p_expr__member(self, p):
"aexpr : aexpr DOT ident"
p[0] = ast.MemberExprAST(self, p[1], p[3])
def p_var(self, p):
"var : ident"
p[0] = ast.VarExprAST(self, p[1])
-
- def p_field(self, p):
- "field : ident"
- p[0] = p[1]