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, 30 Mar 2011 12:48:20
Message-Id: 3bee8e8ccb14837ee561471759536fc7065fc330.betelgeuse@gentoo
1 commit: 3bee8e8ccb14837ee561471759536fc7065fc330
2 Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
3 AuthorDate: Mon Mar 28 14:38:32 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Tue Mar 29 12:19:24 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=3bee8e8c
7
8 Split ARITH_ASSIGN into independent tokens
9
10 It would be easier for the walker to deal with arithmetic assignment if
11 the ARITH_ASSIGN is splitted into independent tokens.
12
13 ---
14 bashast/bashast.g | 16 ++++++++++++----
15 bashast/gunit/arith_main.gunit | 9 +++++++++
16 2 files changed, 21 insertions(+), 4 deletions(-)
17
18 diff --git a/bashast/bashast.g b/bashast/bashast.g
19 index ef87271..948b839 100644
20 --- a/bashast/bashast.g
21 +++ b/bashast/bashast.g
22 @@ -364,7 +364,7 @@ ns_str_part
23 //Parts of strings, no slashes, no reserved words
24 ns_str_part_no_res
25 : num
26 - | name|OTHER|EQUALS|PCT|PCTPCT|MINUS|DOT|DOTDOT|COLON|BOP|UOP|TEST_EXPR|'_'|TILDE|INC|DEC|ARITH_ASSIGN|ESC_CHAR|CARET;
27 + | name|OTHER|EQUALS|PCT|PCTPCT|MINUS|DOT|DOTDOT|COLON|BOP|UOP|TEST_EXPR|'_'|TILDE|INC|DEC|MUL_ASSIGN|DIVIDE_ASSIGN|MOD_ASSIGN|PLUS_ASSIGN|MINUS_ASSIGN|LSHIFT_ASSIGN|RSHIFT_ASSIGN|AND_ASSIGN|XOR_ASSIGN|OR_ASSIGN|ESC_CHAR|CARET;
28 //strings with no slashes, used in certain variable expansions
29 ns_str : ns_str_part* -> ^(STRING ns_str_part*);
30 //Allowable parts of double quoted strings
31 @@ -493,7 +493,7 @@ logicor : logicand (BLANK!* LOGICOR^ BLANK!* logicand)*;
32 arithmetic_condition
33 : cnd=logicor QMARK t=logicor COLON f=logicor -> ^(ARITHMETIC_CONDITION $cnd $t $f);
34 arithmetic_assignment
35 - : (name BLANK!* (EQUALS^|ARITH_ASSIGN^) BLANK!*)? logicor;
36 + : (name BLANK!* (EQUALS|MUL_ASSIGN|DIVIDE_ASSIGN|MOD_ASSIGN|PLUS_ASSIGN|MINUS_ASSIGN|LSHIFT_ASSIGN|RSHIFT_ASSIGN|AND_ASSIGN|XOR_ASSIGN|OR_ASSIGN)^ BLANK!*)? logicor;
37 //process substitution
38 proc_sub: (dir=LESS_THAN|dir=GREATER_THAN)LPAREN BLANK* clist BLANK* RPAREN -> ^(PROC_SUB $dir clist);
39 //the biggie: functions
40 @@ -561,8 +561,16 @@ LESS_THAN : '<';
41 GREATER_THAN : '>';
42 LSHIFT : '<<';
43 RSHIFT : '>>';
44 -ARITH_ASSIGN
45 - : (TIMES|SLASH|PCT|PLUS|MINUS|LSHIFT|RSHIFT|AMP|CARET|PIPE) EQUALS;
46 +MUL_ASSIGN : '*=';
47 +DIVIDE_ASSIGN : '/=';
48 +MOD_ASSIGN : '%=';
49 +PLUS_ASSIGN : '+=';
50 +MINUS_ASSIGN : '-=';
51 +LSHIFT_ASSIGN : '<<=';
52 +RSHIFT_ASSIGN : '>>=';
53 +AND_ASSIGN : '&=';
54 +XOR_ASSIGN : '^=';
55 +OR_ASSIGN : '|=';
56 //some separators
57 SEMIC : ';';
58 DOUBLE_SEMIC
59
60 diff --git a/bashast/gunit/arith_main.gunit b/bashast/gunit/arith_main.gunit
61 index 0c39c9c..ff7f678 100644
62 --- a/bashast/gunit/arith_main.gunit
63 +++ b/bashast/gunit/arith_main.gunit
64 @@ -100,7 +100,16 @@ logicor:
65 arithmetic_assignment:
66 "13"->"13"
67 "foo=5+3" -> (= foo (+ 5 3))
68 +"var *= 5" -> (*= var 5)
69 +"var /= 5" -> (/= var 5)
70 +"var %= 5" -> (%= var 5)
71 "asdf += 5" -> (+= asdf 5)
72 +"var -= 5" -> (-= var 5)
73 +"var <<= 5" -> (<<= var 5)
74 +"var >>= 5" -> (>>= var 5)
75 +"var &= 5" -> (&= var 5)
76 +"var ^= 5" -> (^= var 5)
77 +"var |= 5" -> (|= var 5)
78
79 arithmetic_condition:
80 "5?7:2"->(ARITHMETIC_CONDITION 5 7 2)