aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-07-20 20:26:22 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-07-20 23:15:45 +0800
commitee63385cbb090865646a14fd2c0dd9fd828ad525 (patch)
tree641d695bb9a398a39c83656dfc500745be65722f
parentWalker: reimplement runtime for parameter expansion (diff)
downloadlibbash-ee63385cbb090865646a14fd2c0dd9fd828ad525.tar.gz
libbash-ee63385cbb090865646a14fd2c0dd9fd828ad525.tar.bz2
libbash-ee63385cbb090865646a14fd2c0dd9fd828ad525.zip
Parser: fix delete expansion
-rw-r--r--bashast/bashast.g6
-rw-r--r--bashast/gunit/param_main.gunit2
2 files changed, 5 insertions, 3 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g
index c54adae..9537a0e 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -711,8 +711,8 @@ parameter_expansion
-> ^(parameter_value_operator variable_name parameter_expansion_value)
| COLON BLANK? os=explicit_arithmetic (COLON BLANK? len=explicit_arithmetic)?
-> ^(OFFSET variable_name $os ^($len)?)
- | parameter_delete_operator parameter_replace_pattern
- -> ^(parameter_delete_operator variable_name parameter_replace_pattern)
+ | parameter_delete_operator parameter_delete_pattern
+ -> ^(parameter_delete_operator variable_name parameter_delete_pattern)
| parameter_replace_operator parameter_replace_pattern (SLASH parameter_expansion_value)?
-> ^(parameter_replace_operator variable_name parameter_replace_pattern parameter_expansion_value?)
| BLANK? -> variable_name
@@ -741,6 +741,8 @@ parameter_value_operator
| PLUS -> USE_ALTERNATE_WHEN_UNSET;
parameter_replace_pattern
: ((~SLASH) => parameter_pattern_part)+ -> ^(STRING parameter_pattern_part+);
+parameter_delete_pattern
+ : parameter_pattern_part+ -> ^(STRING parameter_pattern_part+);
parameter_pattern_part
: extended_pattern_match|BLANK|SEMIC;
diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit
index f2b8cbb..677b566 100644
--- a/bashast/gunit/param_main.gunit
+++ b/bashast/gunit/param_main.gunit
@@ -42,7 +42,7 @@ variable_reference:
"${foo%bar}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING bar)))
"${foo%%bar}" -> (VAR_REF (REPLACE_AT_END foo (STRING bar)))
"${foo%; *}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING ; MATCH_ALL)))
-//"${foo%/}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING /)))
+"${foo%/}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING /)))
"${this/is/pattern}"->(VAR_REF (REPLACE_FIRST this (STRING is) (STRING pattern)))
//Test positional/special parameters
"$1" -> (VAR_REF 1)