Gentoo Archives: gentoo-commits

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/
Date: Wed, 27 Apr 2011 15:12:02
Message-Id: d708238429d2687e5362d19e25b5e0bfc6f3eb06.betelgeuse@gentoo
1 commit: d708238429d2687e5362d19e25b5e0bfc6f3eb06
2 Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 27 14:52:45 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 27 14:58:44 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=d7082384
7
8 Parser: support == and != in test built-in
9
10 Virtual token is used instead of OP['..'] because the previous one
11 can't be handled by tree grammar.
12
13 ---
14 bashast/bashast.g | 7 +++++--
15 bashast/gunit/cond_main.gunit | 3 +++
16 2 files changed, 8 insertions(+), 2 deletions(-)
17
18 diff --git a/bashast/bashast.g b/bashast/bashast.g
19 index 9fcacc0..b079d07 100644
20 --- a/bashast/bashast.g
21 +++ b/bashast/bashast.g
22 @@ -94,6 +94,8 @@ tokens{
23 // Avoid ambiguity (being a sign or an operator)
24 PLUS_SIGN;
25 MINUS_SIGN;
26 + // Operators
27 + NOT_EQUALS;
28 }
29
30 start : (flcomment)? EOL* clist BLANK* (SEMIC|AMP|EOL)? -> clist;
31 @@ -335,7 +337,7 @@ builtin_cond_primary
32 | builtin_cond_unary
33 | fname;
34 builtin_cond_binary
35 - : cond_part BLANK!* binary_string_op_builtin^ BLANK!? cond_part;
36 + : cond_part BLANK!* binary_string_op_builtin^ BLANK!* cond_part;
37 builtin_cond_unary
38 : uop^ BLANK!+ cond_part;
39 keyword_cond
40 @@ -355,8 +357,9 @@ binary_str_op_keyword
41 | GREATER_THAN;
42 binary_string_op_builtin
43 : bop
44 + | EQUALS EQUALS -> EQUALS
45 | EQUALS
46 - | BANG EQUALS -> OP["!="]
47 + | BANG EQUALS -> NOT_EQUALS
48 | ESC_LT
49 | ESC_GT;
50 bop : MINUS! NAME^;
51
52 diff --git a/bashast/gunit/cond_main.gunit b/bashast/gunit/cond_main.gunit
53 index 159c734..78ebbf9 100644
54 --- a/bashast/gunit/cond_main.gunit
55 +++ b/bashast/gunit/cond_main.gunit
56 @@ -25,3 +25,6 @@ cond_expr:
57 "[[ \"asdf\" != \"boo\" && -a filename ]]" -> (KEYWORD_TEST (&& (!= (STRING (DOUBLE_QUOTED_STRING asdf)) (STRING (DOUBLE_QUOTED_STRING boo))) (a (STRING filename))))
58 "[[ true ]]" -> (KEYWORD_TEST (STRING true))
59 "[[ true && (false || three) ]]" -> (KEYWORD_TEST (&& (STRING true) (|| (STRING false) (STRING three))))
60 +"[ a = b ]" -> (BUILTIN_TEST (= (STRING a) (STRING b)))
61 +"[ a == b ]" -> (BUILTIN_TEST (= (STRING a) (STRING b)))
62 +"[ a != b ]" -> (BUILTIN_TEST (NOT_EQUALS (STRING a) (STRING b)))