/* * ExpressionParser.cc * * Created on: 02/2019 * Author: akka */ #include #include "ParserLogger.hh" #include "ExpressionParser.hh" #include "ParserGrammar.hh" #include "ExpressionPrinter.hh" #include "Properties.hh" namespace AMDA { namespace parser { bool ExpressionParser::parse(const std::string& str, AMDA::helpers::Properties& lProperties, std::string &kernelExpression, std::vector& paramsList) { LOG4CXX_INFO(gLogger, "ExpressionParser::parse - Try to parse " << str) std::string::const_iterator iter = str.begin(), end = str.end(); try { ParserGrammar grammar(lProperties); Expression::ExpressionContainer expr; bool result = boost::spirit::qi::phrase_parse(iter,end,grammar,boost::spirit::qi::space, expr); if(!result || iter != end) { LOG4CXX_ERROR(gLogger, "ExpressionParser::parse - Cannot parse the expression at -> " << std::string(iter, str.end())) return false; } getExpressionInfo(expr, kernelExpression, paramsList); } catch(...) { LOG4CXX_ERROR(gLogger, "ExpressionParser::parse - An exception occured") return false; } return true; } } /* namespace parser */ } /* namespace AMDA */