Simple calculations can be performed using the constant expression syntax:
{
- check_interval = (15 * 60)
+ check_interval = 30 + 60
}
-Valid operators include ~, +, -, *, /, == and !=. The default precedence rules can be
+Valid operators include ~, +, -, *, /, ==, !=, in and !in. The default precedence rules can be
overridden by grouping expressions using parentheses:
{
- check_interval ((15 * 60) / 2)
+ check_interval (30 + 60) / 2
}
Global constants may be used in constant expressions.
...
{
- check_interval = (MyCheckInterval / 2.5)
+ check_interval = MyCheckInterval / 2.5
}
> **Note**
%type <num> partial_specifier
%type <slist> object_inherits_list
%type <slist> object_inherits_specifier
-%type <aexpr> aterm
%type <aexpr> aexpression
%type <num> variable_decl
%left T_LOGICAL_OR
}
;
-aterm: '(' aexpression ')'
- {
- $$ = $2;
- }
-
aexpression: simplevalue
{
$$ = new Value(make_shared<AExpression>(AEReturn, AValue(ATSimple, *$1), yylloc));
ExpressionList::Ptr exprl = ExpressionList::Ptr($1);
$$ = new Value(exprl);
}
- | aterm
+ | aexpression
{
AExpression::Ptr aexpr = *$1;
$$ = new Value(aexpr->Evaluate(Dictionary::Ptr()));
| T_TEMPLATE
;
-apply: T_APPLY optional_template identifier identifier T_TO identifier T_WHERE aterm
+apply: T_APPLY optional_template identifier identifier T_TO identifier T_WHERE aexpression
{
if (!ApplyRule::IsValidCombination($3, $6)) {
BOOST_THROW_EXCEPTION(std::invalid_argument("'apply' cannot be used with types '" + String($3) + "' and '" + String($6) + "'."));