| 144 | } |
| 145 | |
| 146 | bool MathParser::primary(Expression& expr) |
| 147 | { |
| 148 | if (match(TokenType::Number)) |
| 149 | { |
| 150 | expr.pushNode(NodePtr(new ConstValueNode(curToken().dval()))); |
| 151 | return true; |
| 152 | } |
| 153 | else if (match(TokenType::Identifier)) |
| 154 | { |
| 155 | if (!function(expr)) |
| 156 | expr.pushNode(NodePtr(new VarNode(curToken().sval()))); |
| 157 | return true; |
| 158 | } |
| 159 | bool status = parexpr(expr); |
| 160 | if (!status) |
| 161 | setError("Expecting value expression following '" + curToken().sval() + |
| 162 | "', instead found '" + peekToken().sval() + "'."); |
| 163 | |
| 164 | return status; |
| 165 | } |
| 166 | |
| 167 | bool MathParser::function(Expression& expr) |
| 168 | { |