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.
This commit is contained in:
Jasper St. Pierre 2013-06-27 10:51:19 -04:00
parent 72257d5f69
commit 11fdd5a4ec

View File

@ -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.
@ -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);
}
}