Skip to content
Snippets Groups Projects
Commit ee99f19d authored by Graziano Scalamera's avatar Graziano Scalamera
Browse files

Addes support for attr_name.quality syntax

parent ef864ce9
No related branches found
No related tags found
No related merge requests found
......@@ -3257,11 +3257,22 @@ formula_res_t Alarm::eval_expression(iter_t const& i, string &attr_values, int e
formula_res_t res;
res = eval_expression(i->children.begin(), attr_values);
if (*i->value.begin() == '+')
{
res.value = + res.value;
if (*i->value.begin() == '-')
}
else if (*i->value.begin() == '-')
{
res.value = - res.value;
if (*i->value.begin() == '!')
}
else if (*i->value.begin() == '!')
{
res.value = ! res.value;
}
else
{
err << "in node unary_exprID(" << string(i->value.begin(), i->value.end()) << ") value not allowed" << ends;
throw err.str();
}
return res;
}
else if (i->value.id() == formula_grammar::mult_exprID)
......@@ -3323,6 +3334,12 @@ formula_res_t Alarm::eval_expression(iter_t const& i, string &attr_values, int e
}
if((i->children.begin()+1)->value.id() == formula_grammar::indexID)
ind = eval_expression(i->children.begin()+1, attr_values); //array index
else if(string((i->children.begin()+1)->value.begin(), (i->children.begin()+1)->value.end()) == ".quality")
{
formula_res_t res = eval_expression(i->children.begin(), attr_values, (int)ind.value);
res.value = res.quality;
return res;
}
else
{
err << "in node event_ID(" << string(i->value.begin(), i->value.end()) << ") children2 is not an index ->" << string((i->children.begin()+1)->value.begin(), (i->children.begin()+1)->value.end()) << ends;;
......@@ -3665,17 +3682,6 @@ formula_res_t Alarm::eval_expression(iter_t const& i, string &attr_values, int e
}
else if (string(i->value.begin(), i->value.end()) == string("quality"))
{
if(i->children.size() != 1)
{
err << "in node funcID(" << string(i->value.begin(), i->value.end()) << ") children=" << i->children.size() << ends;
throw err.str();
}
if(i->children.begin()->value.id() != formula_grammar::nameID)
{
string name_id(i->children.begin()->value.begin(), i->children.begin()->value.end());
err << "in node funcID(" << string(i->value.begin(), i->value.end()) << ") children is not an attribute name but " << name_id << ends;
throw err.str();
}
res.value = res.quality;
return res;
}
......
......@@ -168,6 +168,9 @@ struct formula_grammar : public grammar<formula_grammar>
symbol
= (alnum_p | '.' | '_' | '-' | '+') //any alpha numeric char plus '.', '_', '-'
;
symbol_attr
= (alnum_p | '_' ) //any alpha numeric char plus '_' for attribute names
;
//------------------------------ALARM NAME--------------------------------------
name
#if BOOST_VERSION < 103600
......@@ -178,7 +181,7 @@ struct formula_grammar : public grammar<formula_grammar>
lexeme_d[ //needed to ignore "space_p" (skip white spaces) evaluating name
!("tango://" >> (+symbol) >> ':' >> uint_p >> "/") //eventually match FQDN
>> (+symbol) >> '/' >> (+symbol)
>> '/' >> (+symbol) >> '/' >> (+symbol)
>> '/' >> (+symbol) >> '/' >> (+symbol_attr)
]
]
// = repeat_p(3)[(+symbol) >> ch_p('/')] >> (+symbol)
......@@ -228,7 +231,9 @@ struct formula_grammar : public grammar<formula_grammar>
event_
= name
>> !(index)
>> !( (index)
| (".quality")
)
;
/*top = ternary_if;
......@@ -307,7 +312,7 @@ struct formula_grammar : public grammar<formula_grammar>
= ( root_node_d[str_p("abs")] >> (inner_node_d[ch_p('(') >> cond_expr >> ')']) //TODO: ? not expr_atom ?
| root_node_d[str_p("cos")] >> (inner_node_d[ch_p('(') >> cond_expr >> ')']) //TODO: ? not expr_atom ?
| root_node_d[str_p("sin")] >> (inner_node_d[ch_p('(') >> cond_expr >> ')']) //TODO: ? not expr_atom ?
| root_node_d[str_p("quality")] >> (inner_node_d[ch_p('(') >> name >> ')']) //TODO: ? not expr_atom ?
| root_node_d[str_p("quality")] >> (inner_node_d[ch_p('(') >> cond_expr >> ')']) //TODO: ? not expr_atom ?
)
;
function_dual
......@@ -335,15 +340,16 @@ struct formula_grammar : public grammar<formula_grammar>
//| (inner_node_d[ch_p('(') >> non_empty_expression >> ')'])
| (discard_node_d[ch_p('(')] >> non_empty_expression >> discard_node_d[ch_p(')')])
;
logical_expr_paren
/*logical_expr_paren
= (discard_node_d[ch_p('(')] >> logical_expr >> discard_node_d[ch_p(')')])
| logical_expr
;
;*/
}
rule<ScannerT> top;
//rule<ScannerT> symbol;
rule<typename lexeme_scanner<ScannerT>::type> symbol; //needed to use lexeme_d in rule name
rule<typename lexeme_scanner<ScannerT>::type> symbol_attr; //needed to use lexeme_d in rule name
rule<ScannerT, parser_context<>, parser_tag<val_rID> > val_r;
rule<ScannerT, parser_context<>, parser_tag<val_hID> > val_h;
rule<ScannerT, parser_context<>, parser_tag<val_stID> > val_st;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment