From c760a61dd2ffc43c4f72fdfb7aa59949d4e59b06 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 14 Nov 2016 11:52:14 +0200 Subject: [PATCH] Parse true and false as literals rather than identifiers --- source/programparser.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/programparser.cpp b/source/programparser.cpp index f003a835..f11b5bf2 100644 --- a/source/programparser.cpp +++ b/source/programparser.cpp @@ -493,6 +493,12 @@ Expression *ProgramParser::parse_expression(unsigned precedence) expect(")"); left = parexpr; } + else if(isdigit(token[0]) || token=="true" || token=="false") + { + RefPtr literal = new Literal; + literal->token = parse_token(); + left = literal; + } else if(is_identifier(token)) { RefPtr 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 = new Literal; - literal->token = parse_token(); - left = literal; - } else throw runtime_error(format("Parse error at '%s': expected an expression", token)); } -- 2.45.2