diff --git a/src/expressionParser/ExpressionContainer.hh b/src/expressionParser/ExpressionContainer.hh index 47d0ab9..3dacb21 100644 --- a/src/expressionParser/ExpressionContainer.hh +++ b/src/expressionParser/ExpressionContainer.hh @@ -49,25 +49,25 @@ typedef boost::variant >, boost::recursive_wrapper >, boost::recursive_wrapper > -> expressionContainer; +> ExpressionContainer; template struct binop { - explicit binop(const expressionContainer& l, const expressionContainer& r) : oper1(l), oper2(r) { } - expressionContainer oper1, oper2; + explicit binop(const ExpressionContainer& l, const ExpressionContainer& r) : oper1(l), oper2(r) { } + ExpressionContainer oper1, oper2; }; template struct comop { - explicit comop(const expressionContainer& l, const expressionContainer& r) : oper1(l), oper2(r) { } - expressionContainer oper1, oper2; + explicit comop(const ExpressionContainer& l, const ExpressionContainer& r) : oper1(l), oper2(r) { } + ExpressionContainer oper1, oper2; }; template struct unop { - explicit unop(const expressionContainer& o) : oper1(o) { } - expressionContainer oper1; + explicit unop(const ExpressionContainer& o) : oper1(o) { } + ExpressionContainer oper1; }; } /* namespace Expression */ diff --git a/src/expressionParser/ExpressionParser.cc b/src/expressionParser/ExpressionParser.cc index b916871..3b78282 100644 --- a/src/expressionParser/ExpressionParser.cc +++ b/src/expressionParser/ExpressionParser.cc @@ -5,12 +5,7 @@ * Author: akka */ -#include -#include -#include -#include #include -#include #include "ParserLogger.hh" #include "ExpressionParser.hh" @@ -20,15 +15,15 @@ namespace AMDA { namespace parser { -std::string ExpressionParser::parse(const std::string& str) { +std::string ExpressionParser::parse(const std::string& str, AMDA::helpers::Properties& /*lProperties*/) { LOG4CXX_INFO(gLogger, "ExpressionParser::parse - Try to parse " << str) std::string::const_iterator iter = str.begin(), end = str.end(); - parserExpression parser; - Expression::expressionContainer expr; + ParserGrammar grammar; + Expression::ExpressionContainer expr; - bool result = boost::spirit::qi::phrase_parse(iter,end,parser,boost::spirit::qi::space, expr); + bool result = boost::spirit::qi::phrase_parse(iter,end,grammar,boost::spirit::qi::space, expr); if(!result || iter != end) { diff --git a/src/expressionParser/ExpressionParser.hh b/src/expressionParser/ExpressionParser.hh index 4a5feea..b7a838e 100644 --- a/src/expressionParser/ExpressionParser.hh +++ b/src/expressionParser/ExpressionParser.hh @@ -7,6 +7,9 @@ #ifndef EXPRESSIONPARSER_HH_ #define EXPRESSIONPARSER_HH_ + +#include "Properties.hh" + #include namespace AMDA { @@ -23,7 +26,7 @@ public: /** * Exemple of parser */ - static std::string parse(const std::string& s); + static std::string parse(const std::string& s, AMDA::helpers::Properties& lProperties); }; } /* naemspace parser */ diff --git a/src/expressionParser/ExpressionPrinter.hh b/src/expressionParser/ExpressionPrinter.hh index c5a4966..5b80246 100644 --- a/src/expressionParser/ExpressionPrinter.hh +++ b/src/expressionParser/ExpressionPrinter.hh @@ -7,9 +7,10 @@ namespace AMDA { namespace parser { namespace Expression { -struct printer : boost::static_visitor +class ExpressionPrinter : public boost::static_visitor { - printer(std::ostream& os) : _os(os) {} +public: + ExpressionPrinter(std::ostream& os) : _os(os) {} std::ostream& _os; // @@ -42,7 +43,7 @@ struct printer : boost::static_visitor void operator()(const unop& u) const{printUnique("-",u.oper1);} // printer - void print(const std::string& op, const expressionContainer& l, const expressionContainer& r) const + void print(const std::string& op, const ExpressionContainer& l, const ExpressionContainer& r) const { _os << "("; boost::apply_visitor(*this, l); @@ -51,18 +52,18 @@ struct printer : boost::static_visitor _os << ")"; } - void printUnique(const std::string& op, const expressionContainer& l) const + void printUnique(const std::string& op, const ExpressionContainer& l) const { _os << op; boost::apply_visitor(*this, l); } - void printPower(const std::string& op, const expressionContainer& l, const expressionContainer& r) const + void printPower(const std::string& op, const ExpressionContainer& l, const ExpressionContainer& r) const { boost::apply_visitor(*this, l); _os << op; boost::apply_visitor(*this, r); } - void printOutSide(const std::string& op, const expressionContainer& l, const expressionContainer& r) const + void printOutSide(const std::string& op, const ExpressionContainer& l, const ExpressionContainer& r) const { _os << op; _os << "("; @@ -73,9 +74,9 @@ struct printer : boost::static_visitor } }; -std::ostream& operator<<(std::ostream& os, const expressionContainer& e) +std::ostream& operator<<(std::ostream& os, const ExpressionContainer& e) { - boost::apply_visitor(printer(os), e); + boost::apply_visitor(ExpressionPrinter(os), e); return os; } diff --git a/src/expressionParser/Main.cc b/src/expressionParser/Main.cc index a1eda8f..9cef037 100644 --- a/src/expressionParser/Main.cc +++ b/src/expressionParser/Main.cc @@ -66,12 +66,10 @@ int main(int argc, char *argv[]) { vector lExpressionList = vm["expression"].as< vector >(); std::map expressionMap; for(auto expression :lExpressionList){ - LOG4CXX_INFO(logger,"Parasing expression: "< -struct parserExpression : qi::grammar +class ParserGrammar : public qi::grammar { - parserExpression() : parserExpression::base_type(expr_) +public: + ParserGrammar() : ParserGrammar::base_type(expr_) { expr_ = or_.alias(); @@ -72,7 +73,7 @@ struct parserExpression : qi::grammar var_; - qi::rule not_ + qi::rule not_ , and_ , xor_ , or_ -- libgit2 0.21.2