Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ExpressionParser: Add support for the add operator
Use "+" instead of "^" this time.
  • Loading branch information
magcius committed Jun 25, 2013
1 parent 6246f6e commit d2753cc
Showing 1 changed file with 10 additions and 0 deletions.
Expand Up @@ -24,6 +24,7 @@ enum TokenType
TOK_AND,
TOK_OR,
TOK_NOT,
TOK_ADD,
TOK_CONTROL,
};

Expand All @@ -37,6 +38,8 @@ inline std::string OpName(TokenType op)
return "Or";
case TOK_NOT:
return "Not";
case TOK_ADD:
return "Add";
default:
assert(false);
return "";
Expand Down Expand Up @@ -72,6 +75,8 @@ class Token
return "|";
case TOK_NOT:
return "!";
case TOK_ADD:
return "+";
case TOK_CONTROL:
return "Device(" + (std::string)qualifier + ")";
}
Expand Down Expand Up @@ -144,6 +149,8 @@ class Lexer {
return Token(TOK_OR);
case '!':
return Token(TOK_NOT);
case '+':
return Token(TOK_ADD);
case '`':
return GetControlQualifier();
default:
Expand Down Expand Up @@ -232,6 +239,8 @@ class BinaryExpression : public ExpressionNode
return std::min(lhsValue, rhsValue);
case TOK_OR:
return std::max(lhsValue, rhsValue);
case TOK_ADD:
return std::min(lhsValue + rhsValue, 1.0f);
default:
assert(false);
return 0;
Expand Down Expand Up @@ -412,6 +421,7 @@ class Parser
{
case TOK_AND:
case TOK_OR:
case TOK_ADD:
return true;
default:
return false;
Expand Down

0 comments on commit d2753cc

Please sign in to comment.