diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2011-07-22 16:10:59 +0800 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2011-08-02 15:46:29 +0800 |
commit | b6a7f5f3676b27710c8e47ed1a37c90915e75e1c (patch) | |
tree | 2736c30bdc34071ee67997cb2761f85279f07313 /bashast/bashast.g | |
parent | Parser: fix the rule for expansion pattern (diff) | |
download | libbash-b6a7f5f3676b27710c8e47ed1a37c90915e75e1c.tar.gz libbash-b6a7f5f3676b27710c8e47ed1a37c90915e75e1c.tar.bz2 libbash-b6a7f5f3676b27710c8e47ed1a37c90915e75e1c.zip |
Parser: fix array size expansion
The token for "##" is removed in order to support ${##}.
Diffstat (limited to 'bashast/bashast.g')
-rw-r--r-- | bashast/bashast.g | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g index fae2137..c4ab527 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -678,7 +678,7 @@ ns_string_part |OTHER|EQUALS|PCT|PCTPCT|PLUS|MINUS|DOT|DOTDOT|COLON|TEST_EXPR |TILDE|MUL_ASSIGN|DIVIDE_ASSIGN|MOD_ASSIGN |LSHIFT_ASSIGN|RSHIFT_ASSIGN|AND_ASSIGN|XOR_ASSIGN|LSQUARE|RSQUARE - |OR_ASSIGN|CARET|POUND|POUNDPOUND|COMMA|EXPORT|LOCAL|AT + |OR_ASSIGN|CARET|POUND|COMMA|EXPORT|LOCAL|AT // The following is for filename expansion |TIMES|QMARK; @@ -774,10 +774,10 @@ parameter_expansion | LSQUARE (op=TIMES|op=AT) RSQUARE -> ^(LIST_EXPAND variable_name_for_bang $op) | -> ^(VAR_REF variable_name_for_bang) ) - | variable_size_ref; + | {LA(1) == POUND && LA(2) != RBRACE }? => variable_size_ref; parameter_delete_operator - : POUND -> LAZY_REMOVE_AT_START - | POUNDPOUND -> REPLACE_AT_START + : (POUND POUND) => POUND POUND -> REPLACE_AT_START + | POUND -> LAZY_REMOVE_AT_START | PCT -> LAZY_REMOVE_AT_END | PCTPCT -> REPLACE_AT_END; parameter_value_operator @@ -840,8 +840,8 @@ variable_name_no_digit variable_name_for_bang : num|name|POUND; variable_size_ref - : POUND name LSQUARE array_size_index RSQUARE -> ^(POUND ^(name array_size_index)) - | POUND^ name; + : (POUND name LSQUARE) => POUND name LSQUARE array_size_index RSQUARE -> ^(POUND ^(name array_size_index)) + | POUND^ variable_name; array_size_index : DIGIT+ | (AT|TIMES) -> ARRAY_SIZE; @@ -1038,7 +1038,6 @@ ALPHANUM : (DIGIT|LETTER); TILDE : '~'; HERE_STRING_OP : '<<<'; POUND : '#'; -POUNDPOUND : '##'; PCT : '%'; PCTPCT : '%%'; SLASH : '/'; |