diff options
author | 2011-07-27 14:27:47 +0800 | |
---|---|---|
committer | 2011-08-02 15:52:18 +0800 | |
commit | 5752979a8a8320c3bf3606055aa69e0fc202969e (patch) | |
tree | 1e25e9bb80d09483bb4bccbc17010b9723a357ac /bashast | |
parent | Utility: add isolated functions for instruo (diff) | |
download | libbash-5752979a8a8320c3bf3606055aa69e0fc202969e.tar.gz libbash-5752979a8a8320c3bf3606055aa69e0fc202969e.tar.bz2 libbash-5752979a8a8320c3bf3606055aa69e0fc202969e.zip |
Parser: improve exported variable handling
The double quotes were not reserved when calling export. So when the
walker called back to parser, the white spaces inside double quotes
would be problematic. Now this is fixed.
Diffstat (limited to 'bashast')
-rw-r--r-- | bashast/bashast.g | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g index 2a0b23a..55a499d 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -445,7 +445,7 @@ local_item #endif } ->; export_item - : ((~EOL) => (string_expr_part|BLANK|LPAREN|RPAREN))+; + : ((~EOL) => expansion_base)+; builtin_variable_definitions : (builtin_variable_definition_atom) (BLANK builtin_variable_definition_atom)* @@ -681,22 +681,23 @@ quoted_string | SINGLE_QUOTED_STRING_TOKEN -> ^(SINGLE_QUOTED_STRING SINGLE_QUOTED_STRING_TOKEN); double_quoted_string - : DQUOTE double_quoted_string_part* DQUOTE -> ^(DOUBLE_QUOTED_STRING double_quoted_string_part*); -double_quoted_string_part + : DQUOTE ((~DQUOTE) => expansion_base)* DQUOTE -> ^(DOUBLE_QUOTED_STRING expansion_base*); + +// Perform all kinds of expansions +expansion_base : (DOLLAR (LBRACE|name|num|TIMES|AT|POUND|QMARK|MINUS|DOLLAR|BANG)) => variable_reference | (command_substitution) => command_substitution | (DOLLAR (LLPAREN|LSQUARE)) => arithmetic_expansion | (ESC DQUOTE) => ESC DQUOTE -> DQUOTE | (ESC TICK) => ESC TICK -> TICK | (ESC DOLLAR) => ESC DOLLAR -> DOLLAR - | ~(TICK|DQUOTE); + | .; -// Perform all kinds of expansions all_expansions : expansion_atom+ -> ^(STRING expansion_atom+); expansion_atom : (DQUOTE) => double_quoted_string - | double_quoted_string_part; + | expansion_base; string_part : ns_string_part |