From: Mikko Rasa Date: Mon, 14 Nov 2016 09:52:14 +0000 (+0200) Subject: Parse true and false as literals rather than identifiers X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c760a61dd2ffc43c4f72fdfb7aa59949d4e59b06;p=libs%2Fgl.git Parse true and false as literals rather than identifiers --- 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)); }