aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-07-22 18:38:07 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-08-02 15:52:16 +0800
commit10a48abd4df32b33d70b4b73857af96219564301 (patch)
tree48461cbb53da629fbc1b765c6c47589a3cf89a6f
parentParser&Walker: support escaped characters in string (diff)
downloadlibbash-10a48abd4df32b33d70b4b73857af96219564301.tar.gz
libbash-10a48abd4df32b33d70b4b73857af96219564301.tar.bz2
libbash-10a48abd4df32b33d70b4b73857af96219564301.zip
Parser: allow command name that starts with 'test'
-rw-r--r--bashast/bashast.g4
-rw-r--r--bashast/features_script/features.sh.tokens2
-rw-r--r--bashast/gunit/simp_command.gunit1
3 files changed, 4 insertions, 3 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g
index d55a392..dd14f24 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -546,7 +546,7 @@ condition_comparison
condition_expr
: LSQUARE LSQUARE wspace keyword_condition wspace RSQUARE RSQUARE -> ^(KEYWORD_TEST keyword_condition)
| LSQUARE wspace builtin_condition wspace RSQUARE -> ^(BUILTIN_TEST builtin_condition)
- | TEST_EXPR wspace builtin_condition-> ^(BUILTIN_TEST builtin_condition);
+ | TEST_EXPR wspace? builtin_condition-> ^(BUILTIN_TEST builtin_condition);
keyword_condition
: ((BANG) => keyword_negation_primary|keyword_condition_primary) (BLANK!? (LOGICOR^|LOGICAND^) BLANK!? keyword_condition)?;
@@ -1044,7 +1044,7 @@ SLASH : '/';
COLON : ':';
QMARK : '?';
-TEST_EXPR : 'test';
+TEST_EXPR : 'test ';
LOCAL : 'local';
EXPORT : 'export';
LOGICAND : '&&';
diff --git a/bashast/features_script/features.sh.tokens b/bashast/features_script/features.sh.tokens
index af1b075..fc55123 100644
--- a/bashast/features_script/features.sh.tokens
+++ b/bashast/features_script/features.sh.tokens
@@ -85,7 +85,7 @@
85 BLANK NAME BLANK DQUOTE NAME BLANK NAME DQUOTE EOL
86 DONE EOL
87
-88 IF BLANK TEST_EXPR BLANK DIGIT BLANK MINUS NAME BLANK DIGIT SEMIC BLANK THEN EOL
+88 IF BLANK TEST_EXPR DIGIT BLANK MINUS NAME BLANK DIGIT SEMIC BLANK THEN EOL
89 BLANK NAME BLANK DQUOTE NAME SQUOTE LETTER BLANK NAME DQUOTE EOL
90 FI EOL
91
diff --git a/bashast/gunit/simp_command.gunit b/bashast/gunit/simp_command.gunit
index 8e9a443..fdd4346 100644
--- a/bashast/gunit/simp_command.gunit
+++ b/bashast/gunit/simp_command.gunit
@@ -34,3 +34,4 @@ command_atom:
command:
"asdf=5 cat out.log > result" -> (COMMAND (STRING cat) (STRING out . log) (= asdf (STRING 5)) (REDIR > (STRING result)))
"cat results.log > asdf 2> /dev/null" -> (COMMAND (STRING cat) (STRING results . log) (REDIR > (STRING asdf)) (REDIR 2 > (STRING / dev / null)))
+"test-parser a b c" -> (COMMAND (STRING test - parser) (STRING a) (STRING b) (STRING c))