ExpressionParser.cc
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* ExpressionParser.cc
*
* Created on: 02/2019
* Author: akka
*/
#include <sstream>
#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<std::string>& paramsList) {
LOG4CXX_INFO(gLogger, "ExpressionParser::parse - Try to parse " << str)
std::string::const_iterator iter = str.begin(), end = str.end();
try {
ParserGrammar<std::string::const_iterator,boost::spirit::qi::space_type> 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 + 1, 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 */