diff options
author | Mark Spruiell <mes@zeroc.com> | 2003-10-23 03:24:19 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2003-10-23 03:24:19 +0000 |
commit | b65cd40d85bc7bd62ad5042f1644710f08264e53 (patch) | |
tree | 4acbdc8a2583379efcacf91f7d6b8d399ba39149 /cpp/src | |
parent | adding support for dictionary addition, sequence length changes (diff) | |
download | ice-b65cd40d85bc7bd62ad5042f1644710f08264e53.tar.bz2 ice-b65cd40d85bc7bd62ad5042f1644710f08264e53.tar.xz ice-b65cd40d85bc7bd62ad5042f1644710f08264e53.zip |
adding != operator
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Transform/Grammar.y | 7 | ||||
-rw-r--r-- | cpp/src/Transform/Node.cpp | 12 | ||||
-rw-r--r-- | cpp/src/Transform/Node.h | 2 | ||||
-rw-r--r-- | cpp/src/Transform/Scanner.l | 1 |
4 files changed, 20 insertions, 2 deletions
diff --git a/cpp/src/Transform/Grammar.y b/cpp/src/Transform/Grammar.y index 11ef1e04220..4bcb8285b60 100644 --- a/cpp/src/Transform/Grammar.y +++ b/cpp/src/Transform/Grammar.y @@ -65,6 +65,7 @@ transform_error(const char* s) %token TOK_LESS_EQUAL %token TOK_GREATER_EQUAL %token TOK_EQUAL +%token TOK_NEQ %token TOK_TRUE %token TOK_FALSE %token TOK_NIL @@ -76,7 +77,7 @@ transform_error(const char* s) %left TOK_OR %left TOK_AND -%nonassoc TOK_LESS_THAN TOK_GREATER_THAN TOK_LESS_EQUAL TOK_GREATER_EQUAL TOK_EQUAL +%nonassoc TOK_LESS_THAN TOK_GREATER_THAN TOK_LESS_EQUAL TOK_GREATER_EQUAL TOK_EQUAL TOK_NEQ %left TOK_ADD TOK_SUB %left TOK_MUL TOK_DIV TOK_MOD %right UNARY_OP @@ -124,6 +125,10 @@ binary { $$ = new BinaryNode(BinOpEq, parseDataFactory, $1, $3); } +| binary TOK_NEQ binary +{ + $$ = new BinaryNode(BinOpNotEq, parseDataFactory, $1, $3); +} | binary TOK_OR binary { $$ = new BinaryNode(BinOpOr, parseDataFactory, $1, $3); diff --git a/cpp/src/Transform/Node.cpp b/cpp/src/Transform/Node.cpp index 4743be5e1f3..9b37554f172 100644 --- a/cpp/src/Transform/Node.cpp +++ b/cpp/src/Transform/Node.cpp @@ -288,6 +288,15 @@ Transform::BinaryNode::evaluate(SymbolTable& st) result = _factory->createBoolean(b, true); break; } + + case BinOpNotEq: + { + DataPtr leftValue = _left->evaluate(st); + DataPtr rightValue = _right->evaluate(st); + bool b = leftValue == rightValue; + result = _factory->createBoolean(!b, true); + break; + } } if(!result) @@ -347,6 +356,9 @@ Transform::BinaryNode::opToString(BinaryOperator op) case BinOpEq: return "=="; + + case BinOpNotEq: + return "!="; } assert(false); diff --git a/cpp/src/Transform/Node.h b/cpp/src/Transform/Node.h index 54d0333eeb7..dcebd33cdaa 100644 --- a/cpp/src/Transform/Node.h +++ b/cpp/src/Transform/Node.h @@ -69,7 +69,7 @@ enum BinaryOperator BinOpOr, BinOpAnd, BinOpMul, BinOpDiv, BinOpMod, BinOpAdd, BinOpSub, - BinOpLess, BinOpGreater, BinOpLessEq, BinOpGrEq, BinOpEq + BinOpLess, BinOpGreater, BinOpLessEq, BinOpGrEq, BinOpEq, BinOpNotEq }; class BinaryNode : public Node diff --git a/cpp/src/Transform/Scanner.l b/cpp/src/Transform/Scanner.l index b870db79ff9..00e6f3ce2b6 100644 --- a/cpp/src/Transform/Scanner.l +++ b/cpp/src/Transform/Scanner.l @@ -181,6 +181,7 @@ floating_literal (({fractional_constant}{exponent_part}?)|([[:digit:]]+{e "<=" return TOK_LESS_EQUAL; ">=" return TOK_GREATER_EQUAL; "==" return TOK_EQUAL; +"!=" return TOK_NEQ; "+" return TOK_ADD; "-" return TOK_SUB; "*" return TOK_MUL; |