ExpressionParser: Support bare words for simple control names
Using backticks for all control names can get a bit grating, so support "A & B" instead of requiring "`A` & `B`".
This commit is contained in:
parent
d2753cce66
commit
a42388d061
|
@ -108,7 +108,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
Token GetControlQualifier()
|
||||
Token GetFullyQualifiedControl()
|
||||
{
|
||||
ControlQualifier qualifier;
|
||||
std::string value;
|
||||
|
@ -126,6 +126,24 @@ public:
|
|||
return Token(TOK_CONTROL, qualifier);
|
||||
}
|
||||
|
||||
Token GetBarewordsControl(char c)
|
||||
{
|
||||
std::string name;
|
||||
name += c;
|
||||
|
||||
while (it != expr.end()) {
|
||||
c = *it;
|
||||
if (!isalpha(c))
|
||||
break;
|
||||
name += c;
|
||||
it++;
|
||||
}
|
||||
|
||||
ControlQualifier qualifier;
|
||||
qualifier.control_name = name;
|
||||
return Token(TOK_CONTROL, qualifier);
|
||||
}
|
||||
|
||||
Token NextToken()
|
||||
{
|
||||
if (it == expr.end())
|
||||
|
@ -152,9 +170,12 @@ public:
|
|||
case '+':
|
||||
return Token(TOK_ADD);
|
||||
case '`':
|
||||
return GetControlQualifier();
|
||||
return GetFullyQualifiedControl();
|
||||
default:
|
||||
return Token(TOK_INVALID);
|
||||
if (isalpha(c))
|
||||
return GetBarewordsControl(c);
|
||||
else
|
||||
return Token(TOK_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue