Skip to content

Commit

Permalink
libdeng2|Script: Detect a missing statement after ':'
Browse files Browse the repository at this point in the history
This Python-like syntax is not accepted in Doomsday Script:

if value:
    print value
  • Loading branch information
skyjake committed Dec 3, 2012
1 parent 907da93 commit 477f565
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions doomsday/libdeng2/src/scriptsys/parser.cpp
Expand Up @@ -570,10 +570,16 @@ Expression *Parser::parseConditionalCompound(Compound &compound, CompoundFlags c
range.token(1).asText() + " was unexpected");
}

if(colon > 0 && colon < dint(range.size()) - 1)
if(colon > 0)
{
// The colon is not the last token. There must be a statement
// continuing on the same line.
if(colon == dint(range.size()) - 1)
{
// The color is the last token: this is most likely a programmer error.
throw MissingTokenError("Parser::parseConditionalCompound",
"Expected at least one token to follow " +
range.token(colon).asText());
}
// There must be a statement continuing on the same line.
_statementRange = _statementRange.startingFrom(colon + 1);
parseStatement(compound);
}
Expand Down

0 comments on commit 477f565

Please sign in to comment.