void Eval::evaluateInfixExpression (const std::string& e, Variant& v) const { // Reduce e to a vector of tokens. Lexer l (e); l.ambiguity (_ambiguity); std::vector <std::pair <std::string, Lexer::Type> > tokens; std::string token; Lexer::Type type; while (l.token (token, type)) tokens.push_back (std::pair <std::string, Lexer::Type> (token, type)); // Parse for syntax checking and operator replacement. if (_debug) context.debug ("[1;37;42mFILTER[0m Infix " + dump (tokens)); infixParse (tokens); if (_debug) context.debug ("[1;37;42mFILTER[0m Infix parsed " + dump (tokens)); // Convert infix --> postfix. infixToPostfix (tokens); if (_debug) context.debug ("[1;37;42mFILTER[0m Postfix " + dump (tokens)); // Call the postfix evaluator. evaluatePostfixStack (tokens, v); }
void Eval::compileExpression (const std::string& e) { // Reduce e to a vector of tokens. Lexer l (e); l.ambiguity (_ambiguity); std::string token; Lexer::Type type; while (l.token (token, type)) { if (_debug) context.debug ("Lexer '" + token + "' " + Lexer::type_name (type)); _compiled.push_back (std::pair <std::string, Lexer::Type> (token, type)); } // Parse for syntax checking and operator replacement. if (_debug) context.debug ("[1;37;42mFILTER[0m Infix " + dump (_compiled)); infixParse (_compiled); if (_debug) context.debug ("[1;37;42mFILTER[0m Infix parsed " + dump (_compiled)); // Convert infix --> postfix. infixToPostfix (_compiled); if (_debug) context.debug ("[1;37;42mFILTER[0m Postfix " + dump (_compiled)); }
void Eval::compileExpression ( const std::vector <std::pair <std::string, Lexer::Type>>& precompiled) { _compiled = precompiled; // Parse for syntax checking and operator replacement. if (_debug) context.debug ("[1;37;42mFILTER[0m Infix " + dump (_compiled)); infixParse (_compiled); if (_debug) context.debug ("[1;37;42mFILTER[0m Infix parsed " + dump (_compiled)); // Convert infix --> postfix. infixToPostfix (_compiled); if (_debug) context.debug ("[1;37;42mFILTER[0m Postfix " + dump (_compiled)); }