[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; }
%left T_SHIFT_LEFT T_SHIFT_RIGHT
%left T_PLUS T_MINUS
%left T_MULTIPLY T_DIVIDE_OP
+%left UNARY_MINUS
%right '!' '~'
%left '.' '(' '['
%right ';' ','
{
$$ = new NegateExpression($2, DebugInfoRange(@1, @2));
}
+ | T_MINUS rterm %prec UNARY_MINUS
+ {
+ $$ = new SubtractExpression(MakeLiteral(0), $2, DebugInfoRange(@1, @2));
+ }
| rterm_array
{
$$ = $1;
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;