From c92a82fd4aa6864a74a96c0d1f6f806232d653f1 Mon Sep 17 00:00:00 2001 From: skyjake Date: Thu, 29 Nov 2012 21:26:58 +0200 Subject: [PATCH] Fixed|libdeng2: Script parser bug related to ':' in if statement If the condition expression contained a ':', it was confused for the ':' that may come after the expression. --- doomsday/libdeng2/src/scriptsys/parser.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/doomsday/libdeng2/src/scriptsys/parser.cpp b/doomsday/libdeng2/src/scriptsys/parser.cpp index 6a59c2547c..ec30038999 100644 --- a/doomsday/libdeng2/src/scriptsys/parser.cpp +++ b/doomsday/libdeng2/src/scriptsys/parser.cpp @@ -199,7 +199,7 @@ void Parser::parseStatement(Compound &compound) IfStatement *Parser::parseIfStatement() { // The "end" keyword is necessary in the full form. - bool expectEnd = !_statementRange.has(Token::COLON); + bool expectEnd = !_statementRange.hasBracketless(Token::COLON); auto_ptr statement(new IfStatement()); statement->newBranch(); @@ -209,7 +209,7 @@ IfStatement *Parser::parseIfStatement() while(_statementRange.beginsWith(ScriptLex::ELSIF)) { - expectEnd = !_statementRange.has(Token::COLON); + expectEnd = !_statementRange.hasBracketless(Token::COLON); statement->newBranch(); statement->setBranchCondition( parseConditionalCompound(statement->branchCompound(), @@ -280,9 +280,10 @@ ExpressionStatement *Parser::parseImportStatement() "Expected identifier to follow " + _statementRange.firstToken().asText()); } dint startAt = 1; - Expression::Flags flags = Expression::Import - | Expression::NotInScope - | Expression::LocalOnly; + Expression::Flags flags = + Expression::Import | + Expression::NotInScope | + Expression::LocalOnly; if(_statementRange.size() >= 3 && _statementRange.token(1).equals(ScriptLex::RECORD)) { // Take a copy of the imported record instead of referencing it. @@ -524,7 +525,7 @@ Expression *Parser::parseConditionalCompound(Compound &compound, CompoundFlags c TokenRange range = _statementRange; // See if there is a colon on this line. - dint colon = range.find(Token::COLON); + dint colon = range.findBracketless(Token::COLON); auto_ptr condition; if(flags.testFlag(HasCondition))