diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2012-03-26 18:14:42 +0800 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2012-03-26 20:04:43 +0800 |
commit | c8b13641610f4f6b37b15a91f9f5ff390071545e (patch) | |
tree | 04cd4916b41090540b95e06bdec74c84226944ed /bashast | |
parent | Walker: support appending array to array (diff) | |
download | libbash-c8b13641610f4f6b37b15a91f9f5ff390071545e.tar.gz libbash-c8b13641610f4f6b37b15a91f9f5ff390071545e.tar.bz2 libbash-c8b13641610f4f6b37b15a91f9f5ff390071545e.zip |
Parser&Walker: improve escaped double quote handling
Diffstat (limited to 'bashast')
-rw-r--r-- | bashast/bashast.g | 3 | ||||
-rw-r--r-- | bashast/gunit/fname.gunit | 2 | ||||
-rw-r--r-- | bashast/libbashWalker.g | 1 |
3 files changed, 4 insertions, 2 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g index c836047..f7ce358 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -784,7 +784,7 @@ ns_string_part |OTHER|EQUALS|PCT|PCTPCT|PLUS|MINUS|DOT|DOTDOT|COLON |TILDE|LSQUARE|RSQUARE|CARET|POUND|COMMA|EXPORT|LOCAL|AT // Escaped characters - |ESC_RPAREN|ESC_LPAREN|ESC_DOLLAR|ESC_GT|ESC_LT|ESC_TICK + |ESC_RPAREN|ESC_LPAREN|ESC_DOLLAR|ESC_GT|ESC_LT|ESC_TICK|ESC_DQUOTE // The following is for filename expansion |TIMES|QMARK; @@ -1126,6 +1126,7 @@ AMP_RSHIFT : '&>>'; SEMIC : ';'; DOUBLE_SEMIC : ';;'; PIPE : '|'; +ESC_DQUOTE : '\\"'; DQUOTE : '"' { if(LA(-1) != '\\') double_quoted = !double_quoted; }; SQUOTE : { double_quoted }? => '\''; SINGLE_QUOTED_STRING_TOKEN : { !double_quoted }? => '\'' .* '\''; diff --git a/bashast/gunit/fname.gunit b/bashast/gunit/fname.gunit index 9ac0b25..65bb614 100644 --- a/bashast/gunit/fname.gunit +++ b/bashast/gunit/fname.gunit @@ -77,4 +77,4 @@ condition_expr: "[[ x == ab!(gh|i) ]]" -> (KEYWORD_TEST (MATCH_PATTERN (STRING x) (STRING ab (EXTENDED_MATCH_NONE (BRANCH gh) (BRANCH i))))) double_quoted_string: -"\"\\\\\"\$\`\"" -> (DOUBLE_QUOTED_STRING \ " \$ \`) +"\"\\\\\"\$\`\"" -> (DOUBLE_QUOTED_STRING \ \" \$ \`) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index 5d5b557..fb1ca55 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -446,6 +446,7 @@ options {backtrack = true;} :ESC_RPAREN { $libbash_value = ")"; } |ESC_LPAREN { $libbash_value = "("; } |ESC_DOLLAR { $libbash_value = "$"; } + |ESC_DQUOTE { $libbash_value = "\""; } |ESC_GT { $libbash_value = ">"; } |ESC_LT { $libbash_value = "<"; } |ESC_TICK { $libbash_value = "`"; } |