diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2011-07-21 17:48:34 +0800 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2011-08-02 15:46:29 +0800 |
commit | 52b5991a8814319c36677d37440a93470b2fa16c (patch) | |
tree | 95c7547b8c6535f20961b779cb4a9f6c2f46e5bd | |
parent | Walker: support == in arithmetic comparison (diff) | |
download | libbash-52b5991a8814319c36677d37440a93470b2fa16c.tar.gz libbash-52b5991a8814319c36677d37440a93470b2fa16c.tar.bz2 libbash-52b5991a8814319c36677d37440a93470b2fa16c.zip |
Parser: support -a and -i option for local
-rw-r--r-- | bashast/bashast.g | 11 | ||||
-rw-r--r-- | scripts/var_def.bash | 7 |
2 files changed, 17 insertions, 1 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g index fee25b6..6566a5b 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -136,6 +136,8 @@ tokens{ C_INCLUDE #include <string> C_INCLUDE #include <boost/numeric/conversion/cast.hpp> + + C_INCLUDE #include "core/exceptions.h" } @members { @@ -393,7 +395,14 @@ array_atom local_item : variable_definition_atom - | name -> ^(EQUALS name); + | name -> ^(EQUALS name) + | MINUS op=LETTER { +#ifdef OUTPUT_C + std::string option = get_string(op); + if(option != "i" && option != "a") + throw libbash::unsupported_exception("We do not support -" + option + " for local"); +#endif + } ->; export_item : variable_definition_atom | name ->; diff --git a/scripts/var_def.bash b/scripts/var_def.bash index fe2441d..6dc83dd 100644 --- a/scripts/var_def.bash +++ b/scripts/var_def.bash @@ -75,3 +75,10 @@ FOO005=abc echo $FOO005 FOO005+=def echo $FOO005 +function foo() { + local -i foo=1 + local -a bar=(1 2 3) + echo $foo + echo ${bar[@]} +} +foo |