Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ExpressionParser: Search for control names first
Otherwise, valid control names like "Cursor X+" would be incorrectly
tokenized as "`Cursor` `X` +", causing the parser to first abort trying to
find a control named `Cursor` rather than aborting with invalid syntax on
the bad binop.

We could also do this by resolving devices lazily, but since simple
control name bindings are going to be 90% of usecases, just look for these
first.
  • Loading branch information
magcius committed Jun 27, 2013
1 parent 72257d5 commit 11fdd5a
Showing 1 changed file with 1 addition and 10 deletions.
Expand Up @@ -573,15 +573,6 @@ ExpressionParseStatus ParseExpressionInner(std::string str, ControlFinder &finde

ExpressionParseStatus ParseExpression(std::string str, ControlFinder &finder, Expression **expr_out)
{
ExpressionParseStatus status;

status = ParseExpressionInner(str, finder, expr_out);
if (status == EXPRESSION_PARSE_SUCCESS)
return status;

if (status != EXPRESSION_PARSE_SYNTAX_ERROR)
return status;

// Add compatibility with old simple expressions, which are simple
// barewords control names.

Expand All @@ -595,7 +586,7 @@ ExpressionParseStatus ParseExpression(std::string str, ControlFinder &finder, Ex
return EXPRESSION_PARSE_SUCCESS;
}

return EXPRESSION_PARSE_SYNTAX_ERROR;
return ParseExpressionInner(str, finder, expr_out);
}

}
Expand Down

0 comments on commit 11fdd5a

Please sign in to comment.