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: Sun, 17 Apr 2011 10:59:08
Message-Id: 0827ad788f2799814598c6b013abc2a5da76c703.betelgeuse@gentoo
1 commit: 0827ad788f2799814598c6b013abc2a5da76c703
2 Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
3 AuthorDate: Fri Apr 15 14:27:07 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Sun Apr 17 10:44:28 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=0827ad78
7
8 Parser: blanks in parameter replace pattern
9
10 We now support replacements like ${foo// }. The white space handling in
11 this area is still insufficient after this change but it gets us
12 further along in parsing versionator.
13
14 ---
15 bashast/bashast.g | 4 +++-
16 bashast/gunit/param_main.gunit | 1 +
17 2 files changed, 4 insertions(+), 1 deletions(-)
18
19 diff --git a/bashast/bashast.g b/bashast/bashast.g
20 index 67353e3..a7d150c 100644
21 --- a/bashast/bashast.g
22 +++ b/bashast/bashast.g
23 @@ -253,7 +253,9 @@ var_exp : var_name (USE_DEFAULT|USE_ALTERNATE|DISPLAY_ERROR|ASSIGN_DEFAULT)^ wor
24 | TIMES
25 | AT;
26 parameter_pattern
27 - : ((~SLASH) => fname_part)+ -> ^(STRING fname_part+);
28 + : ((~SLASH) => parameter_pattern_part)+ -> ^(STRING parameter_pattern_part+);
29 +parameter_pattern_part
30 + : fname_part|BLANK;
31 parameter_replace_string
32 : (SLASH fname|SLASH)? -> fname?;
33 parameter_replace_operator
34
35 diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit
36 index 0d9bd78..8a14dec 100644
37 --- a/bashast/gunit/param_main.gunit
38 +++ b/bashast/gunit/param_main.gunit
39 @@ -52,6 +52,7 @@ var_ref:
40 "$_" -> (VAR_REF _)
41 "${_}" -> (VAR_REF _)
42 "${PV//./_}" -> (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _)))
43 +"${PV// }" -> (VAR_REF (REPLACE_ALL PV (STRING )))
44 "${PV//[-._]/}" -> (VAR_REF (REPLACE_ALL PV (STRING (MATCH_PATTERN - . _))))
45 "${PV/${pattern}/${replace}}" -> (VAR_REF (REPLACE_FIRST PV (STRING (VAR_REF pattern)) (STRING (VAR_REF replace))))
46 "${PV/#foo/bar}" -> (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar)))