ExpressionParser: Add support for the add operator

Use "+" instead of "^" this time.
This commit is contained in:
Jasper St. Pierre 2013-06-14 02:52:07 -04:00
parent 6246f6e815
commit d2753cce66
1 changed files with 10 additions and 0 deletions

View File

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