diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2011-07-21 17:20:13 +0800 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2011-08-02 15:46:29 +0800 |
commit | 2dc5af830837a30b83a74c8ed4e918a3d7c5f3c3 (patch) | |
tree | fe3b26d56dd993abe309113984e72a9ac2f16818 /bashast | |
parent | Parser: allow empty value for sub-array expansion (diff) | |
download | libbash-2dc5af830837a30b83a74c8ed4e918a3d7c5f3c3.tar.gz libbash-2dc5af830837a30b83a74c8ed4e918a3d7c5f3c3.tar.bz2 libbash-2dc5af830837a30b83a74c8ed4e918a3d7c5f3c3.zip |
Parser: support == in arithmetic comparison
Diffstat (limited to 'bashast')
-rw-r--r-- | bashast/bashast.g | 14 | ||||
-rw-r--r-- | bashast/gunit/arith_main.gunit | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g index 7bb8a8b..fee25b6 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -113,6 +113,7 @@ tokens{ MINUS_SIGN; NOT_EQUALS; + EQUALS_TO; BUILTIN_LOGIC; } @@ -864,7 +865,17 @@ arithmetic ); arithmetic_assignment_operator - : EQUALS|MUL_ASSIGN|DIVIDE_ASSIGN|MOD_ASSIGN|PLUS_ASSIGN|MINUS_ASSIGN|LSHIFT_ASSIGN|RSHIFT_ASSIGN|AND_ASSIGN|XOR_ASSIGN|OR_ASSIGN; + : {LA(1) == EQUALS && LA(2) != EQUALS}? => EQUALS + | MUL_ASSIGN + | DIVIDE_ASSIGN + | MOD_ASSIGN + | PLUS_ASSIGN + | MINUS_ASSIGN + | LSHIFT_ASSIGN + | RSHIFT_ASSIGN + | AND_ASSIGN + | XOR_ASSIGN + | OR_ASSIGN; arithmetic_variable_reference : variable_reference -> ^(VAR_REF variable_reference); @@ -910,6 +921,7 @@ compare_operator | GEQ | LESS_THAN | GREATER_THAN + | EQUALS EQUALS -> EQUALS_TO | BANG EQUALS -> NOT_EQUALS; bitwiseand : compare (AMP^ BLANK!? compare)*; diff --git a/bashast/gunit/arith_main.gunit b/bashast/gunit/arith_main.gunit index 1f1a089..5249b5a 100644 --- a/bashast/gunit/arith_main.gunit +++ b/bashast/gunit/arith_main.gunit @@ -80,6 +80,7 @@ arithmetics_test: "17" ->"17" "19<20" -> (< 19 20) "19!=20" -> (NOT_EQUALS 19 20) +"19==20" -> (EQUALS_TO 19 20) //bitwiseand: "17" -> "17" |