From 124fa9ebc1476efa25d275e24e577fad3d1b247e Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 19 Mar 2014 09:38:45 +0100 Subject: [PATCH] Make braces around constant expressions optional. Refs #5789 --- doc/4.1-configuration-syntax.md | 8 ++++---- lib/config/config_parser.yy | 10 ++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/doc/4.1-configuration-syntax.md b/doc/4.1-configuration-syntax.md index 5f71388ef..f8a869cbd 100644 --- a/doc/4.1-configuration-syntax.md +++ b/doc/4.1-configuration-syntax.md @@ -317,14 +317,14 @@ Constants cannot be changed once they are set. 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. @@ -334,7 +334,7 @@ Global constants may be used in constant expressions. ... { - check_interval = (MyCheckInterval / 2.5) + check_interval = MyCheckInterval / 2.5 } > **Note** diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 57118d03c..749b3aafe 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -123,7 +123,6 @@ using namespace icinga; %type partial_specifier %type object_inherits_list %type object_inherits_specifier -%type aterm %type aexpression %type variable_decl %left T_LOGICAL_OR @@ -584,11 +583,6 @@ simplevalue: T_STRING } ; -aterm: '(' aexpression ')' - { - $$ = $2; - } - aexpression: simplevalue { $$ = new Value(make_shared(AEReturn, AValue(ATSimple, *$1), yylloc)); @@ -700,7 +694,7 @@ value: simplevalue ExpressionList::Ptr exprl = ExpressionList::Ptr($1); $$ = new Value(exprl); } - | aterm + | aexpression { AExpression::Ptr aexpr = *$1; $$ = new Value(aexpr->Evaluate(Dictionary::Ptr())); @@ -712,7 +706,7 @@ optional_template: /* empty */ | 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) + "'.")); -- 2.40.0