def p_Number(p): '''Number : NUMBER | MINUS NUMBER''' if (len(p) == 2): p[0] = AstNode(AST_NUMBER,p.lineno(1),p.lexpos(1),p[1]); elif(len(p) == 3): p[0] = AstNode(AST_NUMBER,p.lineno(2),p.lexpos(2),'-'+p[2]); else: errMsg = '\nBehram error when parsing for number. Incorrect '; errMsg += 'num statements when matching.\n'; errPrint(errMsg); assert(False); p[0].type = TYPE_NUMBER;
def p_Bool(p): '''Bool : TRUE | FALSE''' p[0] = AstNode(AST_BOOL,p.lineno(1),p.lexpos(1),p[1]); p[0].type = TYPE_BOOL;
def p_String(p): '''String : MULTI_LINE_STRING | SINGLE_LINE_STRING'''; p[0] = AstNode(AST_STRING,p.lineno(1),p.lexpos(1),p[1]); p[0].type = TYPE_STRING;