1 |
commit: 3316cbc65d294bd54022a86ed86433ae7a65fc93 |
2 |
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon May 30 09:25:00 2011 +0000 |
4 |
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jun 1 06:12:20 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=3316cbc6 |
7 |
|
8 |
Parser: fix brace expansion |
9 |
|
10 |
We need to support expansions like {$a/$b,c}. The previous |
11 |
implementation can not match $a/$b as a whole string. Now it's fixed. |
12 |
|
13 |
--- |
14 |
bashast/bashast.g | 6 ++---- |
15 |
bashast/gunit/brace.gunit | 1 + |
16 |
2 files changed, 3 insertions(+), 4 deletions(-) |
17 |
|
18 |
diff --git a/bashast/bashast.g b/bashast/bashast.g |
19 |
index 88a44cf..104dd36 100644 |
20 |
--- a/bashast/bashast.g |
21 |
+++ b/bashast/bashast.g |
22 |
@@ -180,10 +180,8 @@ brace_expansion_inside |
23 |
range : DIGIT DOTDOT^ DIGIT |
24 |
| LETTER DOTDOT^ LETTER; |
25 |
brace_expansion_part |
26 |
- : brace_expansion |
27 |
- | ((~COMMA) => fname_part)+ -> ^(STRING fname_part+) |
28 |
- | var_ref |
29 |
- | command_sub |
30 |
+ : (((~COMMA) => fname_part)+ -> ^(STRING fname_part+))+ |
31 |
+ | brace_expansion |
32 |
| -> EMPTY_BRACE_EXPANSION_ATOM; |
33 |
commasep: brace_expansion_part(COMMA! brace_expansion_part)+; |
34 |
command_sub |
35 |
|
36 |
diff --git a/bashast/gunit/brace.gunit b/bashast/gunit/brace.gunit |
37 |
index c9a7ba9..584face 100644 |
38 |
--- a/bashast/gunit/brace.gunit |
39 |
+++ b/bashast/gunit/brace.gunit |
40 |
@@ -20,6 +20,7 @@ gunit bashast; |
41 |
|
42 |
brace_expansion: |
43 |
"{a,b}"-> (BRACE_EXP (STRING a) (STRING b)) |
44 |
+"{$a/$b,b}"-> (BRACE_EXP (STRING (VAR_REF a) / (VAR_REF b)) (STRING b)) |
45 |
"{a,b,c}" -> (BRACE_EXP (STRING a) (STRING b) (STRING c)) |
46 |
"{a..d}" -> (BRACE_EXP (.. a d)) |
47 |
"{{a,b},c,d}" -> (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)) |