fixed a bug in the FUNCTIONS parsing. Now the AST is generated correctly also for (sin(par1)), etc. Also added gamma_mu in FUNCTIONS

This commit is contained in:
nemu
2008-02-18 07:43:57 +00:00
parent db679bfee0
commit 18a45afea1
6 changed files with 116 additions and 115 deletions

View File

@ -29,6 +29,8 @@ short term:
* implement max.likelihood fits **DONE** 08-02-06 (for Single Histo only. * implement max.likelihood fits **DONE** 08-02-06 (for Single Histo only.
For the others not clear how to do it.) For the others not clear how to do it.)
* fix problems in FUNCTIONS of the form (sin(par1)) **DONE** 08-02-18
* implement table based theory functions (LF stuff) * implement table based theory functions (LF stuff)
* if a parameter is not used at all, minuit is still varying it!! This is stupid. * if a parameter is not used at all, minuit is still varying it!! This is stupid.

View File

@ -164,6 +164,9 @@ void PFunction::FillFuncEvalTree(iter_t const& i, PFuncTreeNode &node)
} else if (i->value.id() == PFunctionGrammar::constPiID) { // handle constant pi } else if (i->value.id() == PFunctionGrammar::constPiID) { // handle constant pi
node.fID = PFunctionGrammar::constPiID; // keep the ID node.fID = PFunctionGrammar::constPiID; // keep the ID
node.fDvalue = 3.14159265358979323846; // keep the value node.fDvalue = 3.14159265358979323846; // keep the value
} else if (i->value.id() == PFunctionGrammar::constGammaMuID) { // handle constant gamma_mu
node.fID = PFunctionGrammar::constGammaMuID; // keep the ID
node.fDvalue = 0.01355; // keep the value
} else if (i->value.id() == PFunctionGrammar::parameterID) { // handle parameter number } else if (i->value.id() == PFunctionGrammar::parameterID) { // handle parameter number
str = string(i->value.begin(), i->value.end()); // get string str = string(i->value.begin(), i->value.end()); // get string
status = sscanf(str.c_str(), "PAR%d", &ivalue); // convert string to parameter number status = sscanf(str.c_str(), "PAR%d", &ivalue); // convert string to parameter number
@ -180,9 +183,7 @@ void PFunction::FillFuncEvalTree(iter_t const& i, PFuncTreeNode &node)
// keep the id // keep the id
node.fID = PFunctionGrammar::functionID; node.fID = PFunctionGrammar::functionID;
// keep function tag // keep function tag
// i: 'funcName', '(', 'expression', ')' str = string(i->value.begin(), i->value.end()); // get string
iter_t it = i->children.begin();
str = string(it->value.begin(), it->value.end()); // get string
// cout << endl << ">> functionID: value = " << str; // cout << endl << ">> functionID: value = " << str;
if (!strcmp(str.c_str(), "COS")) if (!strcmp(str.c_str(), "COS"))
node.fFunctionTag = FUN_COS; node.fFunctionTag = FUN_COS;
@ -220,8 +221,8 @@ void PFunction::FillFuncEvalTree(iter_t const& i, PFuncTreeNode &node)
} }
// add node // add node
node.children.push_back(child); node.children.push_back(child);
// i: 'funcName', '(', 'expression', ')' // i: '(', 'expression', ')'
FillFuncEvalTree(i->children.begin()+2, node.children[0]); FillFuncEvalTree(i->children.begin()+1, node.children[0]);
} else if (i->value.id() == PFunctionGrammar::factorID) { } else if (i->value.id() == PFunctionGrammar::factorID) {
// cout << endl << ">> factorID"; // cout << endl << ">> factorID";
// keep the id // keep the id
@ -306,6 +307,8 @@ bool PFunction::FindAndCheckMapAndParamRange(PFuncTreeNode &node, unsigned int m
return true; return true;
} else if (node.fID == PFunctionGrammar::constPiID) { } else if (node.fID == PFunctionGrammar::constPiID) {
return true; return true;
} else if (node.fID == PFunctionGrammar::constGammaMuID) {
return true;
} else if (node.fID == PFunctionGrammar::parameterID) { } else if (node.fID == PFunctionGrammar::parameterID) {
if (node.fIvalue <= (int) paramSize) if (node.fIvalue <= (int) paramSize)
return true; return true;
@ -365,6 +368,8 @@ double PFunction::EvalNode(PFuncTreeNode &node)
return node.fDvalue; return node.fDvalue;
} else if (node.fID == PFunctionGrammar::constPiID) { } else if (node.fID == PFunctionGrammar::constPiID) {
return node.fDvalue; return node.fDvalue;
} else if (node.fID == PFunctionGrammar::constGammaMuID) {
return node.fDvalue;
} else if (node.fID == PFunctionGrammar::parameterID) { } else if (node.fID == PFunctionGrammar::parameterID) {
return fParam[node.fIvalue-1]; return fParam[node.fIvalue-1];
} else if (node.fID == PFunctionGrammar::mapID) { } else if (node.fID == PFunctionGrammar::mapID) {
@ -496,6 +501,8 @@ void PFunction::EvalTreeForStringExpression(iter_t const& i)
fFuncString += ")"; fFuncString += ")";
} else if (i->value.id() == PFunctionGrammar::constPiID) { } else if (i->value.id() == PFunctionGrammar::constPiID) {
fFuncString += "Pi"; fFuncString += "Pi";
} else if (i->value.id() == PFunctionGrammar::constGammaMuID) {
fFuncString += "gamma_mu";
} else if (i->value.id() == PFunctionGrammar::funLabelID) { } else if (i->value.id() == PFunctionGrammar::funLabelID) {
assert(i->children.size() == 0); assert(i->children.size() == 0);
//SetFuncNo(i); //SetFuncNo(i);
@ -507,12 +514,11 @@ void PFunction::EvalTreeForStringExpression(iter_t const& i)
assert(i->children.size() == 0); assert(i->children.size() == 0);
fFuncString += string(i->value.begin(), i->value.end()).c_str(); fFuncString += string(i->value.begin(), i->value.end()).c_str();
} else if (i->value.id() == PFunctionGrammar::functionID) { } else if (i->value.id() == PFunctionGrammar::functionID) {
assert(i->children.size() == 4); assert(i->children.size() == 3);
iter_t it = i->children.begin(); fFuncString += string(i->value.begin(), i->value.end()).c_str(); // keep function name
// funcName, '(', expression, ')'
fFuncString += string(it->value.begin(), it->value.end()).c_str();
fFuncString += "("; fFuncString += "(";
EvalTreeForStringExpression(i->children.begin()+2); // the real stuff // '(', expression, ')'
EvalTreeForStringExpression(i->children.begin()+1); // the real stuff
fFuncString += ")"; fFuncString += ")";
} else if (i->value.id() == PFunctionGrammar::factorID) { } else if (i->value.id() == PFunctionGrammar::factorID) {
EvalTreeForStringExpression(i->children.begin()); EvalTreeForStringExpression(i->children.begin());

View File

@ -51,16 +51,17 @@ typedef parse_tree_match_t::tree_iterator iter_t;
*/ */
struct PFunctionGrammar : public grammar<PFunctionGrammar> struct PFunctionGrammar : public grammar<PFunctionGrammar>
{ {
static const int realID = 1; static const int realID = 1;
static const int constPiID = 2; static const int constPiID = 2;
static const int funLabelID = 3; static const int constGammaMuID = 3;
static const int parameterID = 4; static const int funLabelID = 4;
static const int mapID = 5; static const int parameterID = 5;
static const int functionID = 6; static const int mapID = 6;
static const int factorID = 7; static const int functionID = 7;
static const int termID = 8; static const int factorID = 8;
static const int expressionID = 9; static const int termID = 9;
static const int assignmentID = 10; static const int expressionID = 10;
static const int assignmentID = 11;
template <typename ScannerT> template <typename ScannerT>
struct definition struct definition
@ -68,57 +69,61 @@ struct PFunctionGrammar : public grammar<PFunctionGrammar>
definition(PFunctionGrammar const& /*self*/) definition(PFunctionGrammar const& /*self*/)
{ {
// Start grammar definition // Start grammar definition
real = leaf_node_d[ real_p ]; real = leaf_node_d[ real_p ];
const_pi = leaf_node_d[ str_p("PI") ]; const_pi = leaf_node_d[ str_p("PI") ];
fun_label = leaf_node_d[ ( lexeme_d[ "FUN" >> +digit_p ] ) ]; const_gamma_mu = leaf_node_d[ str_p("GAMMA_MU") ];
parameter = leaf_node_d[ ( lexeme_d[ "PAR" >> +digit_p ] ) ]; fun_label = leaf_node_d[ ( lexeme_d[ "FUN" >> +digit_p ] ) ];
map = leaf_node_d[ ( lexeme_d[ "MAP" >> +digit_p ] ) ]; parameter = leaf_node_d[ ( lexeme_d[ "PAR" >> +digit_p ] ) ];
function = str_p("COS") >> ch_p('(') >> expression >> ch_p(')') map = leaf_node_d[ ( lexeme_d[ "MAP" >> +digit_p ] ) ];
| str_p("SIN") >> ch_p('(') >> expression >> ch_p(')')
| str_p("TAN") >> ch_p('(') >> expression >> ch_p(')')
| str_p("COSH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("SINH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("TANH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ACOS") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ASIN") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ATAN") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ACOSH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ASINH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ATANH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("LOG") >> ch_p('(') >> expression >> ch_p(')')
| str_p("LN") >> ch_p('(') >> expression >> ch_p(')')
| str_p("EXP") >> ch_p('(') >> expression >> ch_p(')')
;
factor = real function = lexeme_d[ root_node_d[ str_p("COS") ] >> ch_p('(') ] >> expression >> ch_p(')')
| const_pi | lexeme_d[ root_node_d[ str_p("SIN") ] >> ch_p('(') ] >> expression >> ch_p(')')
| parameter | lexeme_d[ root_node_d[ str_p("TAN") ] >> ch_p('(') ] >> expression >> ch_p(')')
| map | lexeme_d[ root_node_d[ str_p("COSH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| function | lexeme_d[ root_node_d[ str_p("SINH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| inner_node_d[ch_p('(') >> expression >> ch_p(')')] | lexeme_d[ root_node_d[ str_p("TANH") ] >> ch_p('(') ] >> expression >> ch_p(')')
; | lexeme_d[ root_node_d[ str_p("ACOS") ] >> ch_p('(') ] >> expression >> ch_p(')')
| lexeme_d[ root_node_d[ str_p("ASIN") ] >> ch_p('(') ] >> expression >> ch_p(')')
| lexeme_d[ root_node_d[ str_p("ATAN") ] >> ch_p('(') ] >> expression >> ch_p(')')
| lexeme_d[ root_node_d[ str_p("ACOSH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| lexeme_d[ root_node_d[ str_p("ASINH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| lexeme_d[ root_node_d[ str_p("ATANH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| lexeme_d[ root_node_d[ str_p("LOG") ] >> ch_p('(') ] >> expression >> ch_p(')')
| lexeme_d[ root_node_d[ str_p("LN") ] >> ch_p('(') ] >> expression >> ch_p(')')
| lexeme_d[ root_node_d[ str_p("EXP") ] >> ch_p('(') ] >> expression >> ch_p(')')
;
term = factor >> factor = real
*( (root_node_d[ch_p('*')] >> factor) | const_pi
| (root_node_d[ch_p('/')] >> factor) | const_gamma_mu
); | parameter
| map
| function
| inner_node_d[ch_p('(') >> expression >> ch_p(')')]
;
expression = term >> term = factor >>
*( (root_node_d[ch_p('+')] >> term) *( (root_node_d[ch_p('*')] >> factor)
| (root_node_d[ch_p('-')] >> term) | (root_node_d[ch_p('/')] >> factor)
); );
assignment = (fun_label >> ch_p('=') >> expression); expression = term >>
*( (root_node_d[ch_p('+')] >> term)
| (root_node_d[ch_p('-')] >> term)
);
assignment = (fun_label >> ch_p('=') >> expression);
// End grammar definition // End grammar definition
// turn on the debugging info. // turn on the debugging info.
BOOST_SPIRIT_DEBUG_RULE(real); BOOST_SPIRIT_DEBUG_RULE(real);
BOOST_SPIRIT_DEBUG_RULE(const_pi); BOOST_SPIRIT_DEBUG_RULE(const_pi);
BOOST_SPIRIT_DEBUG_RULE(const_gamma_mu);
BOOST_SPIRIT_DEBUG_RULE(fun_label); BOOST_SPIRIT_DEBUG_RULE(fun_label);
BOOST_SPIRIT_DEBUG_RULE(parameter); BOOST_SPIRIT_DEBUG_RULE(parameter);
BOOST_SPIRIT_DEBUG_RULE(map); BOOST_SPIRIT_DEBUG_RULE(map);
@ -137,6 +142,7 @@ struct PFunctionGrammar : public grammar<PFunctionGrammar>
rule<ScannerT, parser_context<>, parser_tag<mapID> > map; rule<ScannerT, parser_context<>, parser_tag<mapID> > map;
rule<ScannerT, parser_context<>, parser_tag<parameterID> > parameter; rule<ScannerT, parser_context<>, parser_tag<parameterID> > parameter;
rule<ScannerT, parser_context<>, parser_tag<funLabelID> > fun_label; rule<ScannerT, parser_context<>, parser_tag<funLabelID> > fun_label;
rule<ScannerT, parser_context<>, parser_tag<constGammaMuID> > const_gamma_mu;
rule<ScannerT, parser_context<>, parser_tag<constPiID> > const_pi; rule<ScannerT, parser_context<>, parser_tag<constPiID> > const_pi;
rule<ScannerT, parser_context<>, parser_tag<realID> > real; rule<ScannerT, parser_context<>, parser_tag<realID> > real;

View File

@ -161,9 +161,9 @@ bool PFunction::CheckParameterAndMapInTree(iter_t const& i)
fValid = false; fValid = false;
} }
} else if (i->value.id() == PFunctionGrammar::functionID) { } else if (i->value.id() == PFunctionGrammar::functionID) {
assert(i->children.size() == 4); assert(i->children.size() == 3);
// i: 'funcName', '(', 'expression', ')' // i: '(', 'expression', ')'
success = CheckParameterAndMapInTree(i->children.begin()+2); // thats the real stuff success = CheckParameterAndMapInTree(i->children.begin()+1); // thats the real stuff
} else if (i->value.id() == PFunctionGrammar::factorID) { } else if (i->value.id() == PFunctionGrammar::factorID) {
// i: real | parameter | map | function | expression // i: real | parameter | map | function | expression
assert(i->children.size() == 1); assert(i->children.size() == 1);
@ -268,9 +268,8 @@ void PFunction::FillFuncEvalTree(iter_t const& i, PFuncTreeNode &node)
// keep the id // keep the id
node.fID = PFunctionGrammar::functionID; node.fID = PFunctionGrammar::functionID;
// keep function tag // keep function tag
// i: 'funcName', '(', 'expression', ')' // i: '(', 'expression', ')'
iter_t it = i->children.begin(); str = string(i->value.begin(), i->value.end()); // get string
str = string(it->value.begin(), it->value.end()); // get string
// cout << endl << ">> functionID: value = " << str; // cout << endl << ">> functionID: value = " << str;
if (!strcmp(str.c_str(), "COS")) if (!strcmp(str.c_str(), "COS"))
node.fFunctionTag = FUN_COS; node.fFunctionTag = FUN_COS;
@ -308,8 +307,8 @@ void PFunction::FillFuncEvalTree(iter_t const& i, PFuncTreeNode &node)
} }
// add node // add node
node.children.push_back(child); node.children.push_back(child);
// i: 'funcName', '(', 'expression', ')' // i: '(', 'expression', ')'
FillFuncEvalTree(i->children.begin()+2, node.children[0]); FillFuncEvalTree(i->children.begin()+1, node.children[0]);
} else if (i->value.id() == PFunctionGrammar::factorID) { } else if (i->value.id() == PFunctionGrammar::factorID) {
// cout << endl << ">> factorID"; // cout << endl << ">> factorID";
// keep the id // keep the id
@ -534,19 +533,16 @@ long PFunction::EvalTreeExpression(iter_t const& i)
cout << endl << "-----"; cout << endl << "-----";
fFuncString += string(i->value.begin(), i->value.end()); fFuncString += string(i->value.begin(), i->value.end());
} else if (i->value.id() == PFunctionGrammar::functionID) { } else if (i->value.id() == PFunctionGrammar::functionID) {
assert(i->children.size() == 4); assert(i->children.size() == 3);
cout << endl << "functionID: children = " << i->children.size(); cout << endl << "functionID: children = " << i->children.size();
iter_t it = i->children.begin(); cout << endl << "functionID: value = " << string(i->value.begin(), i->value.end());
cout << endl << "functionID: value = " << string(it->value.begin(), it->value.end());
cout << endl << "-----"; cout << endl << "-----";
// funcName, '(', expression, ')' // '(', expression, ')'
counter++; counter++;
fFuncString += string(it->value.begin(), it->value.end()); fFuncString += string(i->value.begin(), i->value.end());
if (termOp == 0) fFuncString += "(";
fFuncString += "("; EvalTreeExpression(i->children.begin()+1); // the real stuff
EvalTreeExpression(i->children.begin()+2); // the real stuff fFuncString += ")";
if (termOp == 0)
fFuncString += ")";
counter--; counter--;
} else if (i->value.id() == PFunctionGrammar::factorID) { } else if (i->value.id() == PFunctionGrammar::factorID) {
cout << endl << "factorID: children = " << i->children.size(); cout << endl << "factorID: children = " << i->children.size();
@ -555,58 +551,50 @@ long PFunction::EvalTreeExpression(iter_t const& i)
counter--; counter--;
} else if (i->value.id() == PFunctionGrammar::termID) { } else if (i->value.id() == PFunctionGrammar::termID) {
cout << endl << "termID: children = " << i->children.size(); cout << endl << "termID: children = " << i->children.size();
counter++;
termOp++;
if (*i->value.begin() == '*') { if (*i->value.begin() == '*') {
cout << endl << "termID: '*'"; cout << endl << "termID: '*'";
assert(i->children.size() == 2); assert(i->children.size() == 2);
counter++;
termOp++;
EvalTreeExpression(i->children.begin()); EvalTreeExpression(i->children.begin());
fFuncString += " * "; fFuncString += " * ";
EvalTreeExpression(i->children.begin()+1); EvalTreeExpression(i->children.begin()+1);
termOp--;
counter--;
} else if (*i->value.begin() == '/') { } else if (*i->value.begin() == '/') {
cout << endl << "termID: '/'"; cout << endl << "termID: '/'";
assert(i->children.size() == 2); assert(i->children.size() == 2);
counter++;
termOp++;
EvalTreeExpression(i->children.begin()); EvalTreeExpression(i->children.begin());
fFuncString += " / "; fFuncString += " / ";
EvalTreeExpression(i->children.begin()+1); EvalTreeExpression(i->children.begin()+1);
termOp--;
counter--;
} else { } else {
assert(0); assert(0);
} }
termOp--;
counter--;
} else if (i->value.id() == PFunctionGrammar::expressionID) { } else if (i->value.id() == PFunctionGrammar::expressionID) {
cout << endl << "expressionID: children = " << i->children.size(); cout << endl << "expressionID: children = " << i->children.size();
if (termOp > 0)
fFuncString += "(";
if (*i->value.begin() == '+') { if (*i->value.begin() == '+') {
cout << endl << "expressionID: '+'"; cout << endl << "expressionID: '+'";
assert(i->children.size() == 2); assert(i->children.size() == 2);
counter++; counter++;
if (termOp > 0)
fFuncString += "(";
EvalTreeExpression(i->children.begin()); EvalTreeExpression(i->children.begin());
fFuncString += " + "; fFuncString += " + ";
EvalTreeExpression(i->children.begin()+1); EvalTreeExpression(i->children.begin()+1);
if (termOp > 0)
fFuncString += ")";
counter--; counter--;
} else if (*i->value.begin() == '-') { } else if (*i->value.begin() == '-') {
cout << endl << "expressionID: '-'"; cout << endl << "expressionID: '-'";
assert(i->children.size() == 2); assert(i->children.size() == 2);
counter++; counter++;
if (termOp > 0)
fFuncString += "(";
EvalTreeExpression(i->children.begin()); EvalTreeExpression(i->children.begin());
fFuncString += " - "; fFuncString += " - ";
EvalTreeExpression(i->children.begin()+1); EvalTreeExpression(i->children.begin()+1);
if (termOp > 0)
fFuncString += ")";
counter--; counter--;
} else { } else {
assert(0); assert(0);
} }
if (termOp > 0)
fFuncString += ")";
} else if (i->value.id() == PFunctionGrammar::assignmentID) { } else if (i->value.id() == PFunctionGrammar::assignmentID) {
cout << endl << "assignmentID: children = " << i->children.size(); cout << endl << "assignmentID: children = " << i->children.size();
assert(i->children.size() == 3); assert(i->children.size() == 3);
@ -693,16 +681,15 @@ long PFunction::PrintTreeExpression(iter_t const& i)
} }
} }
} else if (i->value.id() == PFunctionGrammar::functionID) { } else if (i->value.id() == PFunctionGrammar::functionID) {
// i: 'funcName', '(', 'expression', ')' // i: '(', 'expression', ')'
if (i->children.size() == 4) { str = string(i->value.begin(), i->value.end());
cout << endl << ">> " << str;
if (i->children.size() == 3) {
j = i->children.begin(); j = i->children.begin();
str = string(j->value.begin(), j->value.end()); str = string(j->value.begin(), j->value.end());
cout << endl << ">> " << str; cout << endl << ">> " << str;
j = i->children.begin()+1; PrintTreeExpression(i->children.begin()+1);
str = string(j->value.begin(), j->value.end()); j = i->children.begin()+2;
cout << endl << ">> " << str;
PrintTreeExpression(i->children.begin()+2);
j = i->children.begin()+3;
str = string(j->value.begin(), j->value.end()); str = string(j->value.begin(), j->value.end());
cout << endl << ">> " << str; cout << endl << ">> " << str;
} else { } else {

View File

@ -35,7 +35,7 @@
#include <iostream> #include <iostream>
using namespace std; using namespace std;
#define BOOST_SPIRIT_DEBUG //#define BOOST_SPIRIT_DEBUG
#include <boost/spirit/core.hpp> #include <boost/spirit/core.hpp>
#include <boost/spirit/tree/ast.hpp> #include <boost/spirit/tree/ast.hpp>
@ -75,21 +75,21 @@ struct PFunctionGrammar : public grammar<PFunctionGrammar>
map = leaf_node_d[ ( lexeme_d[ "MAP" >> +digit_p ] ) ]; map = leaf_node_d[ ( lexeme_d[ "MAP" >> +digit_p ] ) ];
function = str_p("COS") >> ch_p('(') >> expression >> ch_p(')') function = lexeme_d[ root_node_d[ str_p("COS") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("SIN") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("SIN") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("TAN") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("TAN") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("COSH") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("COSH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("SINH") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("SINH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("TANH") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("TANH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("ACOS") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("ACOS") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("ASIN") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("ASIN") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("ATAN") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("ATAN") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("ACOSH") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("ACOSH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("ASINH") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("ASINH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("ATANH") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("ATANH") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("LOG") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("LOG") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("LN") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("LN") ] >> ch_p('(') ] >> expression >> ch_p(')')
| str_p("EXP") >> ch_p('(') >> expression >> ch_p(')') | lexeme_d[ root_node_d[ str_p("EXP") ] >> ch_p('(') ] >> expression >> ch_p(')')
; ;
factor = real factor = real

View File

@ -18,7 +18,7 @@ PAR 1.0 2.1 3.5 -0.87 0.87
MAP 2 1 4 5 MAP 2 1 4 5
FUNCTIONS FUNCTIONS
#fun0 = sin(par3/(par1+map2)) #fun0 = sin(par3/(par1+map2))
fun1 = cos(par2) fun1 = (sin(par1)*cos(par1)+((map1)))
#fun0 = par1 + map3 * cos(cos(par2 - map1)) #fun0 = par1 + map3 * cos(cos(par2 - map1))
#fun8 = log(sin(par1)) + exp(-1.0*map2) #fun8 = log(sin(par1)) + exp(-1.0*map2)
#fun1 = par1 + map1 * (0.01355+par1*(2.1 - (-2.3 / 3.4))) #fun1 = par1 + map1 * (0.01355+par1*(2.1 - (-2.3 / 3.4)))