diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-08-02 18:39:40 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-08-02 18:39:40 +0200 |
commit | 3d77b28eacc940356e94c36017fb2d9f1a1b7ec2 (patch) | |
tree | abf8ac9c0ea547078885db3ad699bb2da5d25752 /src/libexpr | |
parent | 47701677e88230abf7d9106c55f46aa660643ce7 (diff) |
Add comparison operators ‘<’, ‘<=’, ‘>’ and ‘>=’
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/lexer.l | 2 | ||||
-rw-r--r-- | src/libexpr/parser.y | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l index fe2ff75d0..3b7c6bb57 100644 --- a/src/libexpr/lexer.l +++ b/src/libexpr/lexer.l @@ -101,6 +101,8 @@ or { return OR_KW; } \=\= { return EQ; } \!\= { return NEQ; } +\<\= { return LEQ; } +\>\= { return GEQ; } \&\& { return AND; } \|\| { return OR; } \-\> { return IMPL; } diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index d998c840e..cd1b0e21f 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -269,6 +269,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * err %left OR %left AND %nonassoc EQ NEQ +%left '<' '>' LEQ GEQ %right UPDATE %left NOT %left '+' '-' @@ -312,6 +313,10 @@ expr_op | '-' expr_op %prec NEGATE { $$ = new ExprApp(new ExprApp(new ExprVar(data->symbols.create("__sub")), new ExprInt(0)), $2); } | expr_op EQ expr_op { $$ = new ExprOpEq($1, $3); } | expr_op NEQ expr_op { $$ = new ExprOpNEq($1, $3); } + | expr_op '<' expr_op { $$ = new ExprApp(new ExprApp(new ExprVar(data->symbols.create("__lessThan")), $1), $3); } + | expr_op LEQ expr_op { $$ = new ExprOpNot(new ExprApp(new ExprApp(new ExprVar(data->symbols.create("__lessThan")), $3), $1)); } + | expr_op '>' expr_op { $$ = new ExprApp(new ExprApp(new ExprVar(data->symbols.create("__lessThan")), $3), $1); } + | expr_op GEQ expr_op { $$ = new ExprOpNot(new ExprApp(new ExprApp(new ExprVar(data->symbols.create("__lessThan")), $1), $3)); } | expr_op AND expr_op { $$ = new ExprOpAnd($1, $3); } | expr_op OR expr_op { $$ = new ExprOpOr($1, $3); } | expr_op IMPL expr_op { $$ = new ExprOpImpl($1, $3); } |