mirror of https://github.com/Icinga/icinga2.git
parent
e93595c006
commit
c29d6a99ac
|
@ -265,12 +265,12 @@ in return T_IN;
|
|||
[a-zA-Z_][a-zA-Z0-9\-_]* { yylval->text = strdup(yytext); return T_IDENTIFIER; }
|
||||
@[a-zA-Z_][a-zA-Z0-9\-_]* { yylval->text = strdup(yytext + 1); return T_IDENTIFIER; }
|
||||
\<[^\>]*\> { yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING_ANGLE; }
|
||||
-?[0-9]+(\.[0-9]+)?ms { yylval->num = strtod(yytext, NULL) / 1000; return T_NUMBER; }
|
||||
-?[0-9]+(\.[0-9]+)?d { yylval->num = strtod(yytext, NULL) * 60 * 60 * 24; return T_NUMBER; }
|
||||
-?[0-9]+(\.[0-9]+)?h { yylval->num = strtod(yytext, NULL) * 60 * 60; return T_NUMBER; }
|
||||
-?[0-9]+(\.[0-9]+)?m { yylval->num = strtod(yytext, NULL) * 60; return T_NUMBER; }
|
||||
-?[0-9]+(\.[0-9]+)?s { yylval->num = strtod(yytext, NULL); return T_NUMBER; }
|
||||
-?[0-9]+(\.[0-9]+)? { yylval->num = strtod(yytext, NULL); return T_NUMBER; }
|
||||
[0-9]+(\.[0-9]+)?ms { yylval->num = strtod(yytext, NULL) / 1000; return T_NUMBER; }
|
||||
[0-9]+(\.[0-9]+)?d { yylval->num = strtod(yytext, NULL) * 60 * 60 * 24; return T_NUMBER; }
|
||||
[0-9]+(\.[0-9]+)?h { yylval->num = strtod(yytext, NULL) * 60 * 60; return T_NUMBER; }
|
||||
[0-9]+(\.[0-9]+)?m { yylval->num = strtod(yytext, NULL) * 60; return T_NUMBER; }
|
||||
[0-9]+(\.[0-9]+)?s { yylval->num = strtod(yytext, NULL); return T_NUMBER; }
|
||||
[0-9]+(\.[0-9]+)? { yylval->num = strtod(yytext, NULL); return T_NUMBER; }
|
||||
= { yylval->csop = OpSetLiteral; return T_SET; }
|
||||
\+= { yylval->csop = OpSetAdd; return T_SET_ADD; }
|
||||
-= { yylval->csop = OpSetSubtract; return T_SET_SUBTRACT; }
|
||||
|
|
|
@ -208,6 +208,7 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
|
|||
%left T_SHIFT_LEFT T_SHIFT_RIGHT
|
||||
%left T_PLUS T_MINUS
|
||||
%left T_MULTIPLY T_DIVIDE_OP
|
||||
%left UNARY_MINUS
|
||||
%right '!' '~'
|
||||
%left '.' '(' '['
|
||||
%right ';' ','
|
||||
|
@ -781,6 +782,10 @@ rterm_without_indexer: T_STRING
|
|||
{
|
||||
$$ = new NegateExpression($2, DebugInfoRange(@1, @2));
|
||||
}
|
||||
| T_MINUS rterm %prec UNARY_MINUS
|
||||
{
|
||||
$$ = new SubtractExpression(MakeLiteral(0), $2, DebugInfoRange(@1, @2));
|
||||
}
|
||||
| rterm_array
|
||||
{
|
||||
$$ = $1;
|
||||
|
|
|
@ -98,6 +98,18 @@ BOOST_AUTO_TEST_CASE(simple)
|
|||
BOOST_CHECK(expr->Evaluate(frame) == 20);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "2 * - 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame) == -6);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "-(2 + 3)");
|
||||
BOOST_CHECK(expr->Evaluate(frame) == -5);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "- 2 * 2 - 2 * 3 - 4 * - 5");
|
||||
BOOST_CHECK(expr->Evaluate(frame) == 10);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "!0 == true");
|
||||
BOOST_CHECK(expr->Evaluate(frame));
|
||||
delete expr;
|
||||
|
|
Loading…
Reference in New Issue