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:
Jasper St. Pierre 2013-06-14 03:10:27 -04:00
parent d2753cce66
commit a42388d061
1 changed files with 24 additions and 3 deletions

View File

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