diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2011-07-21 17:00:05 +0800 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2011-08-02 15:46:29 +0800 |
commit | 8d0126787eaf4ee648ebe7f47a8048dc3c15c88e (patch) | |
tree | 518ee16a27b6e4d73c89104fc3d208a2c9741698 | |
parent | Parser: add back more tests (diff) | |
download | libbash-8d0126787eaf4ee648ebe7f47a8048dc3c15c88e.tar.gz libbash-8d0126787eaf4ee648ebe7f47a8048dc3c15c88e.tar.bz2 libbash-8d0126787eaf4ee648ebe7f47a8048dc3c15c88e.zip |
Parser: allow braces in command arguments
-rw-r--r-- | bashast/bashast.g | 8 | ||||
-rw-r--r-- | bashast/gunit/simp_command.gunit | 2 | ||||
-rw-r--r-- | test/walker_test.cpp | 3 |
3 files changed, 9 insertions, 4 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g index 65cc493..14d7d10 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -404,7 +404,13 @@ bash_command_arguments : bash_command_argument_atom+ -> ^(STRING bash_command_argument_atom+); // TODO support brace expansion and braces bash_command_argument_atom - : string_expr_part; + : (LBRACE) => + ( + (brace_expansion) => brace_expansion + |LBRACE + ) + | RBRACE + | string_expr_part; parens : LPAREN BLANK? RPAREN; diff --git a/bashast/gunit/simp_command.gunit b/bashast/gunit/simp_command.gunit index d7b25e9..965b351 100644 --- a/bashast/gunit/simp_command.gunit +++ b/bashast/gunit/simp_command.gunit @@ -28,7 +28,7 @@ command_atom: "cat ~/Documents/todo.txt" -> (STRING cat) (STRING ~ / Documents / todo . txt) "dodir ${foo}/${bar}" -> (STRING dodir) (STRING (VAR_REF foo) / (VAR_REF bar)) "local a=123 b=(1 2 3) c" -> (VARIABLE_DEFINITIONS local (= a (STRING 123)) (= b (ARRAY (STRING 1) (STRING 2) (STRING 3))) (EQUALS c)) -//"echo {}{}}{{{}}{{}" -> (STRING echo) (STRING { } { } } { { { } } { { }) +"echo {}{}}{{{}}{{}" -> (STRING echo) (STRING { } { } } { { { } } { { }) "echo \"ab#af ###\" #abc" -> (STRING echo) (STRING (DOUBLE_QUOTED_STRING ab # af ## #)) command: diff --git a/test/walker_test.cpp b/test/walker_test.cpp index 4a69e9f..4f87c26 100644 --- a/test/walker_test.cpp +++ b/test/walker_test.cpp @@ -91,7 +91,6 @@ TEST(extglob, used_when_disabled) } } -/* TEST(brace_expansion, not_in_raw_string) { interpreter walker; @@ -100,4 +99,4 @@ TEST(brace_expansion, not_in_raw_string) std::istringstream input(script); bash_ast ast(input); EXPECT_THROW(ast.interpret_with(walker), libbash::unsupported_exception); -} */ +} |