Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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`".
  • Loading branch information
magcius committed Jun 25, 2013
1 parent d2753cc commit a42388d
Showing 1 changed file with 24 additions and 3 deletions.
Expand Up @@ -108,7 +108,7 @@ class Lexer {
return false;
}

Token GetControlQualifier()
Token GetFullyQualifiedControl()
{
ControlQualifier qualifier;
std::string value;
Expand All @@ -126,6 +126,24 @@ class Lexer {
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())
Expand All @@ -152,9 +170,12 @@ class Lexer {
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);
}
}

Expand Down

0 comments on commit a42388d

Please sign in to comment.