diff options
author | André Aparício <aparicio99@gmail.com> | 2012-06-19 17:46:40 +0100 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2012-07-20 09:20:22 +0800 |
commit | f9501f5d7ad82d273cab44cd96114d644fb5772d (patch) | |
tree | 8a0639ad40b65f460cdb7409ea94ffc52d7fd67b /bashast | |
parent | Replace boost::scoped_ptr with std::unique_ptr (diff) | |
download | libbash-f9501f5d7ad82d273cab44cd96114d644fb5772d.tar.gz libbash-f9501f5d7ad82d273cab44cd96114d644fb5772d.tar.bz2 libbash-f9501f5d7ad82d273cab44cd96114d644fb5772d.zip |
Builtin: Support variable declarations in declare
Diffstat (limited to 'bashast')
-rw-r--r-- | bashast/bashast.g | 5 | ||||
-rw-r--r-- | bashast/libbashWalker.g | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g index e2702d0..2d425ce 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -398,6 +398,8 @@ command_atom -> ^(STRING EXPORT) ^(STRING builtin_variable_definition_item) | (LOCAL) => LOCAL BLANK builtin_variable_definition_item -> ^(STRING LOCAL) ^(STRING builtin_variable_definition_item) + | (DECLARE) => DECLARE BLANK builtin_variable_definition_item + -> ^(STRING DECLARE) ^(STRING builtin_variable_definition_item) | command_name ( (BLANK? parens) => BLANK? parens wspace? compound_command @@ -782,7 +784,7 @@ string_part ns_string_part : num|name|escaped_character |OTHER|EQUALS|PCT|PCTPCT|PLUS|MINUS|DOT|DOTDOT|COLON - |TILDE|LSQUARE|RSQUARE|CARET|POUND|COMMA|EXPORT|LOCAL|AT + |TILDE|LSQUARE|RSQUARE|CARET|POUND|COMMA|EXPORT|LOCAL|DECLARE|AT // Escaped characters |ESC_RPAREN|ESC_LPAREN|ESC_DOLLAR|ESC_GT|ESC_LT|ESC_TICK|ESC_DQUOTE // The following is for filename expansion @@ -1151,6 +1153,7 @@ QMARK : '?'; LOCAL : 'local'; EXPORT : 'export'; +DECLARE : 'declare'; LOGICAND : '&&'; LOGICOR : '||'; diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index 648dd53..42a8917 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -637,7 +637,8 @@ simple_command std::vector<std::string> libbash_args; bool split; } - :string_expr{ split = ($string_expr.libbash_value != "local" && $string_expr.libbash_value != "export"); } + :string_expr{ split = ($string_expr.libbash_value != "local" && $string_expr.libbash_value != "export" + && $string_expr.libbash_value != "declare"); } (argument[libbash_args, split])* execute_command[$string_expr.libbash_value, libbash_args]; execute_command[std::string& name, std::vector<std::string>& libbash_args] @@ -649,7 +650,7 @@ execute_command[std::string& name, std::vector<std::string>& libbash_args] bool redirection = false; } @init { - if(name != "local" && name != "set") + if(name != "local" && name != "set" && name != "declare") current_scope.reset(new interpreter::local_scope(*walker)); } :var_def[true]* (redirect[out, err, in]{ redirection = true; })* { |