def p_function_expr_2(self, p): """ function_expr \ : FUNCTION identifier LPAREN RPAREN LBRACE function_body RBRACE | FUNCTION identifier LPAREN formal_parameter_list RPAREN \ LBRACE function_body RBRACE """ if len(p) == 8: p[0] = ast.FuncExpr( identifier=p[2], parameters=None, elements=p[6], lineno=p.lineno(2)) else: p[0] = ast.FuncExpr( identifier=p[2], parameters=p[4], elements=p[7], lineno=p.lineno(2))
def p_function_expr_1(self, p): """ function_expr \ : FUNCTION LPAREN RPAREN LBRACE function_body RBRACE | FUNCTION LPAREN formal_parameter_list RPAREN \ LBRACE function_body RBRACE """ if len(p) == 7: p[0] = ast.FuncExpr( identifier=None, parameters=None, elements=p[5], lineno=p.lineno(5)) else: p[0] = ast.FuncExpr( identifier=None, parameters=p[3], elements=p[6], lineno=p.lineno(3))