diff options
author | 2012-03-01 15:51:58 +0800 | |
---|---|---|
committer | 2012-03-01 15:51:58 +0800 | |
commit | 62f2e7c112601d5bc7e7f5d042d4fce1e354865e (patch) | |
tree | 56a71efbe59dd1f2ab1e1e5348880f5f842cfc59 /bashast | |
parent | Parser: allow multiple operands in test expression (diff) | |
download | libbash-62f2e7c112601d5bc7e7f5d042d4fce1e354865e.tar.gz libbash-62f2e7c112601d5bc7e7f5d042d4fce1e354865e.tar.bz2 libbash-62f2e7c112601d5bc7e7f5d042d4fce1e354865e.zip |
Parser: allow empty replacement pattern
Diffstat (limited to 'bashast')
-rw-r--r-- | bashast/bashast.g | 3 | ||||
-rw-r--r-- | bashast/gunit/param_main.gunit | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g index 8d627c4..73249ef 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -879,7 +879,8 @@ parameter_value_operator | QMARK -> DISPLAY_ERROR_WHEN_UNSET | PLUS -> USE_ALTERNATE_WHEN_UNSET; parameter_replace_pattern - : ((~SLASH) => parameter_pattern_part)+ -> ^(STRING parameter_pattern_part+); + : (SLASH) => -> ^(STRING NAME) // Create an empty string + | ((~SLASH) => parameter_pattern_part)+ -> ^(STRING parameter_pattern_part+); parameter_delete_pattern : parameter_pattern_part+ -> ^(STRING parameter_pattern_part+); parameter_pattern_part diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit index 01ec853..2168d54 100644 --- a/bashast/gunit/param_main.gunit +++ b/bashast/gunit/param_main.gunit @@ -90,6 +90,9 @@ variable_reference: "${!#/a/bc}" -> (VAR_REF (REPLACE_FIRST (VAR_REF #) (STRING a) (STRING bc))) "${!abc/a/bc}" -> (VAR_REF (REPLACE_FIRST (VAR_REF abc) (STRING a) (STRING bc))) "${!123/a/bc}" -> (VAR_REF (REPLACE_FIRST (VAR_REF 123) (STRING a) (STRING bc))) +"${search_paths/%/${root}}" -> (VAR_REF (REPLACE_AT_END search_paths (STRING NAME) (STRING $ { root }))) +"${search_paths/#/${root}}" -> (VAR_REF (REPLACE_AT_START search_paths (STRING NAME) (STRING $ { root }))) +"${search_paths//${root}}" -> (VAR_REF (REPLACE_ALL search_paths (STRING (VAR_REF root)))) variable_definition_atom: "MY_PN=${PN/asterisk-}" -> (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) |