Make braces around constant expressions optional.

Refs #5789
This commit is contained in:
Gunnar Beutner 2014-03-19 09:38:45 +01:00
parent f871758502
commit 124fa9ebc1
2 changed files with 6 additions and 12 deletions

View File

@ -317,14 +317,14 @@ Constants cannot be changed once they are set.
Simple calculations can be performed using the constant expression syntax: 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: overridden by grouping expressions using parentheses:
{ {
check_interval ((15 * 60) / 2) check_interval (30 + 60) / 2
} }
Global constants may be used in constant expressions. Global constants may be used in constant expressions.
@ -334,7 +334,7 @@ Global constants may be used in constant expressions.
... ...
{ {
check_interval = (MyCheckInterval / 2.5) check_interval = MyCheckInterval / 2.5
} }
> **Note** > **Note**

View File

@ -123,7 +123,6 @@ using namespace icinga;
%type <num> partial_specifier %type <num> partial_specifier
%type <slist> object_inherits_list %type <slist> object_inherits_list
%type <slist> object_inherits_specifier %type <slist> object_inherits_specifier
%type <aexpr> aterm
%type <aexpr> aexpression %type <aexpr> aexpression
%type <num> variable_decl %type <num> variable_decl
%left T_LOGICAL_OR %left T_LOGICAL_OR
@ -584,11 +583,6 @@ simplevalue: T_STRING
} }
; ;
aterm: '(' aexpression ')'
{
$$ = $2;
}
aexpression: simplevalue aexpression: simplevalue
{ {
$$ = new Value(make_shared<AExpression>(AEReturn, AValue(ATSimple, *$1), yylloc)); $$ = new Value(make_shared<AExpression>(AEReturn, AValue(ATSimple, *$1), yylloc));
@ -700,7 +694,7 @@ value: simplevalue
ExpressionList::Ptr exprl = ExpressionList::Ptr($1); ExpressionList::Ptr exprl = ExpressionList::Ptr($1);
$$ = new Value(exprl); $$ = new Value(exprl);
} }
| aterm | aexpression
{ {
AExpression::Ptr aexpr = *$1; AExpression::Ptr aexpr = *$1;
$$ = new Value(aexpr->Evaluate(Dictionary::Ptr())); $$ = new Value(aexpr->Evaluate(Dictionary::Ptr()));
@ -712,7 +706,7 @@ optional_template: /* empty */
| T_TEMPLATE | 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)) { if (!ApplyRule::IsValidCombination($3, $6)) {
BOOST_THROW_EXCEPTION(std::invalid_argument("'apply' cannot be used with types '" + String($3) + "' and '" + String($6) + "'.")); BOOST_THROW_EXCEPTION(std::invalid_argument("'apply' cannot be used with types '" + String($3) + "' and '" + String($6) + "'."));