]> git.tdb.fi Git - libs/gl.git/commitdiff
Parse true and false as literals rather than identifiers
authorMikko Rasa <tdb@tdb.fi>
Mon, 14 Nov 2016 09:52:14 +0000 (11:52 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 14 Nov 2016 09:52:14 +0000 (11:52 +0200)
source/programparser.cpp

index f003a835b56b0352e7abe2387bcaff24792d87ce..f11b5bf2e73bb570981072de07cf69d6c32e1824 100644 (file)
@@ -493,6 +493,12 @@ Expression *ProgramParser::parse_expression(unsigned precedence)
                                expect(")");
                                left = parexpr;
                        }
+                       else if(isdigit(token[0]) || token=="true" || token=="false")
+                       {
+                               RefPtr<Literal> literal = new Literal;
+                               literal->token = parse_token();
+                               left = literal;
+                       }
                        else if(is_identifier(token))
                        {
                                RefPtr<VariableReference> var = new VariableReference;
@@ -508,12 +514,6 @@ Expression *ProgramParser::parse_expression(unsigned precedence)
                                unary->expression = parse_expression(oper->precedence);
                                left = unary;
                        }
-                       else if(isdigit(token[0]))
-                       {
-                               RefPtr<Literal> literal = new Literal;
-                               literal->token = parse_token();
-                               left = literal;
-                       }
                        else
                                throw runtime_error(format("Parse error at '%s': expected an expression", token));
                }