Commit a0761bdec35587248baaab5f626d04e5775f333b

Authored by Hacene SI HADJ MOHAND
1 parent 9eb1514e

adding function is Ok

src/expressionParser/ExpressionContainer.hh
  1 +#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
  2 +#define BOOST_MPL_LIMIT_LIST_SIZE 30
  3 +#include <boost/mpl/list.hpp>
  4 +
1 5 #ifndef EXPRESSIONCONTAINER_HH_
2 6 #define EXPRESSIONCONTAINER_HH_
3   -#define FUSION_MAX_DEQUE_SIZE 30
  7 +
4 8 namespace AMDA {
5 9 namespace parser {
6 10  
... ... @@ -86,21 +90,21 @@ template &lt;typename tag&gt; struct unop
86 90 };
87 91 template <typename tag> struct triop
88 92 {
89   - explicit triop(const expressionContainer& functionId,
90   - const expressionContainer& l
91   - , const expressionContainer& r)
  93 + explicit triop(const ExpressionContainer& functionId,
  94 + const ExpressionContainer& l
  95 + , const ExpressionContainer& r)
92 96 : oper1(functionId), oper2(l), oper3(r) { }
93   -expressionContainer oper1, oper2, oper3;
  97 +ExpressionContainer oper1, oper2, oper3;
94 98 };
95 99  
96 100 template <typename tag> struct forop
97 101 {
98   - explicit forop(const expressionContainer& functionId,
99   - const expressionContainer& l,
100   - const expressionContainer& m,
101   - const expressionContainer& r)
  102 + explicit forop(const ExpressionContainer& functionId,
  103 + const ExpressionContainer& l,
  104 + const ExpressionContainer& m,
  105 + const ExpressionContainer& r)
102 106 : oper1(functionId), oper2(l), oper3(m),oper4(r) { }
103   -expressionContainer oper1, oper2, oper3,oper4;
  107 +ExpressionContainer oper1, oper2, oper3,oper4;
104 108 };
105 109  
106 110  
... ...
src/expressionParser/ExpressionParser.cc
... ... @@ -5,6 +5,11 @@
5 5 * Author: akka
6 6 */
7 7  
  8 +#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
  9 +#define BOOST_MPL_LIMIT_LIST_SIZE 30
  10 +#include <boost/mpl/list.hpp>
  11 +
  12 +
8 13 #include <sstream>
9 14  
10 15 #include "ParserLogger.hh"
... ...
src/expressionParser/ExpressionPrinter.hh
... ... @@ -48,7 +48,7 @@ public:
48 48 void operator()(const forop<fun_three>& b) const { printFunctionThree(b.oper1, b.oper2, b.oper3, b.oper4); }
49 49 void operator()(const triop<fun_two>& b) const { printFunctionTwo(b.oper1, b.oper2, b.oper3); }
50 50 void operator()(const binop<fun_one>& b) const { printFunctionOne(b.oper1, b.oper2); }
51   -
  51 +
52 52 // printer
53 53 void print(const std::string& op, const ExpressionContainer& l, const ExpressionContainer& r) const
54 54 {
... ... @@ -81,7 +81,7 @@ public:
81 81 _os << ")";
82 82 }
83 83  
84   - void printFunctionThree(const expressionContainer& functionId, const expressionContainer& l, const expressionContainer& m, const expressionContainer& r) const
  84 + void printFunctionThree(const ExpressionContainer& functionId, const ExpressionContainer& l, const ExpressionContainer& m, const ExpressionContainer& r) const
85 85 {
86 86 boost::apply_visitor(*this, functionId);
87 87 _os << "(";
... ... @@ -93,7 +93,7 @@ public:
93 93 _os << ")";
94 94 }
95 95  
96   - void printFunctionTwo(const expressionContainer& functionId, const expressionContainer& l, const expressionContainer& r) const
  96 + void printFunctionTwo(const ExpressionContainer& functionId, const ExpressionContainer& l, const ExpressionContainer& r) const
97 97 {
98 98 boost::apply_visitor(*this, functionId);
99 99 _os << "(";
... ... @@ -103,7 +103,7 @@ public:
103 103 _os << ")";
104 104 }
105 105  
106   - void printFunctionOne(const expressionContainer& functionId, const expressionContainer& l) const
  106 + void printFunctionOne(const ExpressionContainer& functionId, const ExpressionContainer& l) const
107 107 {
108 108 boost::apply_visitor(*this, functionId);
109 109 _os << "(";
... ...
src/expressionParser/ParserGrammar.hh
  1 +#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
  2 +#define BOOST_MPL_LIMIT_LIST_SIZE 30
  3 +#include <boost/mpl/list.hpp>
  4 +
1 5 #ifndef PARSERGRAMMAR_HH_
2 6 #define PARSERGRAMMAR_HH_
3 7  
... ... @@ -47,12 +51,11 @@ public:
47 51 pow_ = fold<funcop<op_power> >(greater_.alias())[powOperator_ >> greater_];
48 52  
49 53 greater_= fold<comop<op_greater> >(lower_.alias())[greaterOperator_ >> lower_];
50   - lower_ = fold<comop<op_lower> >( not_.alias())[lowerOperator_ >> functions_];
  54 + lower_ = fold<comop<op_lower> >( functions_.alias())[lowerOperator_ >> functions_];
51 55  
52 56 functions_ = (threeArgsFunction>>"(">>funArgs_>>componentOperator_>>funArgs_>>componentOperator_>>funArgs_>>")")[_val= boost::phoenix::construct<Expression::forop <fun_three>>(_1,_2,_3,_4)] ||
53 57 (twoArgsFunction>>"(">>funArgs_>>componentOperator_>>funArgs_>>")")[_val= boost::phoenix::construct<Expression::triop <fun_two>>(_1,_2,_3)]||
54 58 (oneArgsFunction>>"(">>funArgs_>>")")[_val= boost::phoenix::construct<Expression::binop <fun_one>>(_1,_2)]|not_[_val=_1];
55   -
56 59 // UNARY OPERATIONS
57 60 not_ = (notOperator_ > const_) [_val = boost::phoenix::construct<Expression::unop <op_not>>(_1)] | const_[_val = _1];
58 61  
... ... @@ -79,6 +82,7 @@ public:
79 82 greaterOrEqualOperator_ = qi::string(">=");
80 83 lowerOrEqualOperator_ = qi::string("<=");
81 84 lowerOperator_ = qi::char_("<");
  85 + componentOperator_ = qi::char_(",");
82 86  
83 87 // Define available constants
84 88 std::map<std::string, std::string> existingConstants = ParserToolbox::getConstants(lProperties);
... ... @@ -95,10 +99,14 @@ public:
95 99 // Defined functions available
96 100 std::map<std::string,FunctionInfo> existingFunctions = ParserToolbox::getFunctions(lProperties);
97 101 for(auto const& x : existingFunctions ) {
98   - if (x.second.getNbArgs()==1) oneArgsFunction.add(x.second.getIHMName(), x.second.getKernelName());
99   - if (x.second.getNbArgs()==2) twoArgsFunction.add(x.second.getIHMName(), x.second.getKernelName());
100   - if (x.second.getNbArgs()==3) threeArgsFunction.add(x.second.getIHMName(), x.second.getKernelName());
101   - }
  102 + if (x.second.getNbArgs()==1) {
  103 + oneArgsFunction.add(x.second.getIHMName(), x.second.getKernelName());
  104 + }else if (x.second.getNbArgs()==2) {
  105 + twoArgsFunction.add(x.second.getIHMName(), x.second.getKernelName());
  106 + }else {
  107 + threeArgsFunction.add(x.second.getIHMName(), x.second.getKernelName());
  108 + }
  109 + }
102 110  
103 111  
104 112 BOOST_SPIRIT_DEBUG_NODES((expr_)(or_)(and_)(equal_)(unequal_)(greaterOrEqual_)(lowerOrEqual_)(lower_)(sum_)
... ... @@ -145,6 +153,7 @@ private:
145 153 , greaterOperator_
146 154 , greaterOrEqualOperator_
147 155 ,lowerOrEqualOperator_
  156 + ,componentOperator_
148 157 ,lowerOperator_ ;
149 158  
150 159 qi::symbols<char, std::string> definedConstants;
... ...