Diagnostics
- Added diagnostic token dump to 'calc' in debug mode, after token substitution so the new tokens can be seen. - Added unit tests to look for parser syntax errors. - Added test for '2--3'.
This commit is contained in:
10
src/Eval.cpp
10
src/Eval.cpp
@@ -106,14 +106,16 @@ void Eval::evaluateInfixExpression (const std::string& e, Variant& v) const
|
||||
std::string token;
|
||||
Lexer::Type type;
|
||||
while (l.token (token, type))
|
||||
{
|
||||
tokens.push_back (std::pair <std::string, Lexer::Type> (token, type));
|
||||
if (_debug)
|
||||
std::cout << "# token infix '" << token << "' " << Lexer::type_name (type) << "\n";
|
||||
}
|
||||
|
||||
// Parse for syntax checking and operator replacement.
|
||||
infixParse (tokens);
|
||||
if (_debug)
|
||||
{
|
||||
std::vector <std::pair <std::string, Lexer::Type> >::iterator i;
|
||||
for (i = tokens.begin (); i != tokens.end (); ++i)
|
||||
std::cout << "# token infix '" << i->first << "' " << Lexer::type_name (i->second) << "\n";
|
||||
}
|
||||
|
||||
// Convert infix --> postfix.
|
||||
infixToPostfix (tokens);
|
||||
|
||||
Reference in New Issue
Block a user