mirror of https://github.com/Icinga/icinga2.git
parent
ce737ff2f3
commit
04b8724cb8
|
@ -65,6 +65,10 @@ Value AExpression::Evaluate(const Object::Ptr& thisRef) const
|
|||
return (long)left << (long)right;
|
||||
case AEShiftRight:
|
||||
return (long)left >> (long)right;
|
||||
case AEEqual:
|
||||
return left == right;
|
||||
case AENotEqual:
|
||||
return left != right;
|
||||
default:
|
||||
ASSERT(!"Invalid operator.");
|
||||
}
|
||||
|
|
|
@ -41,7 +41,9 @@ enum AOperator
|
|||
AEBinaryAnd,
|
||||
AEBinaryOr,
|
||||
AEShiftLeft,
|
||||
AEShiftRight
|
||||
AEShiftRight,
|
||||
AEEqual,
|
||||
AENotEqual,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -232,7 +232,9 @@ const return T_CONST;
|
|||
-?[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->op = OperatorSet; return T_EQUAL; }
|
||||
== { yylval->op = OperatorEqual; return T_EQUAL; }
|
||||
!= { yylval->op = OperatorNotEqual; return T_NOT_EQUAL; }
|
||||
= { yylval->op = OperatorSet; return T_SET; }
|
||||
\+= { yylval->op = OperatorPlus; return T_PLUS_EQUAL; }
|
||||
-= { yylval->op = OperatorMinus; return T_MINUS_EQUAL; }
|
||||
\*= { yylval->op = OperatorMultiply; return T_MULTIPLY_EQUAL; }
|
||||
|
|
|
@ -69,7 +69,9 @@ using namespace icinga;
|
|||
%token <num> T_NUMBER
|
||||
%token T_NULL
|
||||
%token <text> T_IDENTIFIER
|
||||
%token <op> T_EQUAL "= (T_EQUAL)"
|
||||
%token <op> T_EQUAL "== (T_EQUAL)"
|
||||
%token <op> T_NOT_EQUAL "!= (T_NOT_EQUAL)"
|
||||
%token <op> T_SET "= (T_SET)"
|
||||
%token <op> T_PLUS_EQUAL "+= (T_PLUS_EQUAL)"
|
||||
%token <op> T_MINUS_EQUAL "-= (T_MINUS_EQUAL)"
|
||||
%token <op> T_MULTIPLY_EQUAL "*= (T_MULTIPLY_EQUAL)"
|
||||
|
@ -191,7 +193,7 @@ library: T_LIBRARY T_STRING
|
|||
}
|
||||
;
|
||||
|
||||
variable: variable_decl identifier T_EQUAL value
|
||||
variable: variable_decl identifier T_SET value
|
||||
{
|
||||
Value *value = $4;
|
||||
if (value->IsObjectType<ExpressionList>()) {
|
||||
|
@ -480,7 +482,7 @@ expression: identifier operator value
|
|||
}
|
||||
;
|
||||
|
||||
operator: T_EQUAL
|
||||
operator: T_SET
|
||||
| T_PLUS_EQUAL
|
||||
| T_MINUS_EQUAL
|
||||
| T_MULTIPLY_EQUAL
|
||||
|
@ -591,6 +593,18 @@ aexpression: T_STRING
|
|||
$$ = new Value(make_shared<AExpression>(AENegate, static_cast<AExpression::Ptr>(*$2)));
|
||||
delete $2;
|
||||
}
|
||||
| aexpression T_EQUAL aexpression
|
||||
{
|
||||
$$ = new Value(make_shared<AExpression>(AEEqual, static_cast<AExpression::Ptr>(*$1), static_cast<AExpression::Ptr>(*$3)));
|
||||
delete $1;
|
||||
delete $3;
|
||||
}
|
||||
| aexpression T_NOT_EQUAL aexpression
|
||||
{
|
||||
$$ = new Value(make_shared<AExpression>(AENotEqual, static_cast<AExpression::Ptr>(*$1), static_cast<AExpression::Ptr>(*$3)));
|
||||
delete $1;
|
||||
delete $3;
|
||||
}
|
||||
| aexpression '+' aexpression
|
||||
{
|
||||
$$ = new Value(make_shared<AExpression>(AEAdd, static_cast<AExpression::Ptr>(*$1), static_cast<AExpression::Ptr>(*$3)));
|
||||
|
|
|
@ -43,7 +43,9 @@ enum ExpressionOperator
|
|||
OperatorPlus,
|
||||
OperatorMinus,
|
||||
OperatorMultiply,
|
||||
OperatorDivide
|
||||
OperatorDivide,
|
||||
OperatorEqual, /* Not used for Expressions */
|
||||
OperatorNotEqual, /* Not used for Expressions */
|
||||
};
|
||||
|
||||
class ExpressionList;
|
||||
|
|
Loading…
Reference in New Issue