* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-11 6:50 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-11 6:50 UTC (permalink / raw
To: gentoo-commits
commit: ac39c6edd729af0baa3dd19aa7d0ea9735157d60
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sun Apr 10 16:38:35 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Apr 11 06:45:53 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=ac39c6ed
Array indexes are arithmetic expressions
Bash array indexes are arithmetic expressions that evaluate to the index
to be assigned. Now parsing them is supported. The AST might need
improvement by the time we start to support them in the tree grammar.
---
bashast/bashast.g | 7 ++-----
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/assoc_array.gunit | 5 ++++-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 1026169..0a42b4e 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -215,7 +215,7 @@ cond_comparison
//Variables
//Defining a variable
var_def
- : name LSQUARE BLANK? var_index BLANK* RSQUARE EQUALS value -> ^(EQUALS ^(name var_index) value)
+ : name LSQUARE BLANK? arithmetics BLANK* RSQUARE EQUALS value -> ^(EQUALS ^(name arithmetics) value)
| name EQUALS^ value
| LET! name EQUALS^ arithmetic;
//Possible values of a variable
@@ -226,15 +226,12 @@ value : num
//allow the parser to create array variables
arr_val :
| (ag+=val wspace?)+ -> ^(ARRAY $ag+);
-val : LSQUARE! BLANK!* var_index BLANK!? RSQUARE! EQUALS^ pos_val
+val : LSQUARE! BLANK!* arithmetics BLANK!? RSQUARE! EQUALS^ pos_val
| pos_val;
pos_val : command_sub
| var_ref
| num
| fname;
-//possible indexes for the variable. Names are used when it acts more like a map/hash than an array
-var_index : num
- | name;
//Referencing a variable (different possible ways/special parameters)
var_ref
: DOLLAR LBRACE BLANK* var_exp BLANK* RBRACE -> ^(VAR_REF var_exp)
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index c4c57bf..8981c7f 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))))
+(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (COMMAND_SUB (COMMAND (STRING echo) (STRING 6))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) 3) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING
a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STR
ING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (|
(COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (:- asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_LAST PV (STRING foo) (STRING bar))))) (= MY_PN (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))) (| (COMMAND (STRING c
at) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/assoc_array.gunit b/bashast/gunit/assoc_array.gunit
index 53f5386..cdc7b0c 100644
--- a/bashast/gunit/assoc_array.gunit
+++ b/bashast/gunit/assoc_array.gunit
@@ -19,5 +19,8 @@
gunit bashast;
var_def:
-"arr[foo]=\"asdf\"" -> (= (arr foo) (STRING (DOUBLE_QUOTED_STRING asdf)))
+"arr[foo]=\"asdf\"" -> (= (arr (VAR_REF foo)) (STRING (DOUBLE_QUOTED_STRING asdf)))
"arr=(a b [4]=c)" -> (= arr (ARRAY (STRING a) (STRING b) (= 4 (STRING c))))
+"asdf[$idx]=${var}" -> (= (asdf (VAR_REF idx)) (VAR_REF var))
+"asdf[++i]=${var}" -> (= (asdf (PRE_INCR (VAR_REF i))) (VAR_REF var))
+"asdf[++i,j]=${var}" -> (= (asdf (PRE_INCR (VAR_REF i)) (VAR_REF j)) (VAR_REF var))
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-11 6:50 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-11 6:50 UTC (permalink / raw
To: gentoo-commits
commit: 299103634484bcb224553fe2b1b451313c736496
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sun Apr 10 19:25:51 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Apr 11 06:45:53 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=29910363
Simplify array assignment rules
By making the AST root for the assingment value STRING we can remove the
pos_value rule.
---
bashast/bashast.g | 6 +-----
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/array.gunit | 4 ++--
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 985f929..9f0f80c 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -223,11 +223,7 @@ value : num
//allow the parser to create array variables
arr_val :
| (ag+=val wspace?)+ -> ^(ARRAY $ag+);
-val : LSQUARE! BLANK!* explicit_arithmetic BLANK!? RSQUARE! EQUALS^ pos_val
- | pos_val;
-pos_val : command_sub
- | var_ref
- | num
+val : LSQUARE! BLANK!* explicit_arithmetic BLANK!? RSQUARE! EQUALS^ fname
| fname;
//Referencing a variable (different possible ways/special parameters)
var_ref
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 8981c7f..b8c361e 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (COMMAND_SUB (COMMAND (STRING echo) (STRING 6))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) 3) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING
a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STR
ING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (|
(COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (:- asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_LAST PV (STRING foo) (STRING bar))))) (= MY_PN (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))) (| (COMMAND (STRING c
at) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) 3) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EX
P (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (RED
IR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr /
bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (:- asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_LAST PV (STRING foo) (STRING bar))))) (= MY_PN (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))) (| (COMMAND
(STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/array.gunit b/bashast/gunit/array.gunit
index 105c333..5fd47db 100644
--- a/bashast/gunit/array.gunit
+++ b/bashast/gunit/array.gunit
@@ -20,8 +20,8 @@ gunit bashast;
var_def:
"asdf=(a b c d)"->(= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))
-"asdf=(`echo 6` b c d)"->(= asdf (ARRAY (COMMAND_SUB (COMMAND (STRING echo) (STRING 6))) (STRING b) (STRING c) (STRING d)))
-"asdf=(${P} b c d)"->(= asdf (ARRAY (VAR_REF P) (STRING b) (STRING c) (STRING d)))
+"asdf=(`echo 6` b c d)"->(= asdf (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d)))
+"asdf=(${P} b c d)"->(= asdf (ARRAY (STRING (VAR_REF P)) (STRING b) (STRING c) (STRING d)))
var_ref:
"$asdf" -> (VAR_REF asdf)
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-12 7:19 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-12 7:19 UTC (permalink / raw
To: gentoo-commits
commit: 482c9b0ea12c6ee951d894ecbe2e709994394046
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Mon Apr 11 07:08:25 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Apr 11 13:46:58 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=482c9b0e
Fix assignment FOO=1aa
Handling all assignment values through fname means we support values
like 1aa. Fixes bug #363031.
---
bashast/bashast.g | 9 ++++-----
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/assoc_array.gunit | 8 ++++----
bashast/gunit/param_main.gunit | 3 ++-
bashast/gunit/simp_command.gunit | 6 +++---
bashast/libbashWalker.g | 6 ++----
6 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 9f0f80c..29e24e2 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -216,14 +216,13 @@ var_def
| name EQUALS^ value
| LET! name EQUALS^ arithmetic;
//Possible values of a variable
-value : num
- | var_ref
- | fname
+value : fname
| LPAREN! wspace!? arr_val RPAREN!;
//allow the parser to create array variables
arr_val :
- | (ag+=val wspace?)+ -> ^(ARRAY $ag+);
-val : LSQUARE! BLANK!* explicit_arithmetic BLANK!? RSQUARE! EQUALS^ fname
+ | (ag+=array_atom wspace?)+ -> ^(ARRAY $ag+);
+array_atom
+ : LSQUARE! BLANK!* explicit_arithmetic BLANK!? RSQUARE! EQUALS^ fname
| fname;
//Referencing a variable (different possible ways/special parameters)
var_ref
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index b8c361e..317c41a 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) 3) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EX
P (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (RED
IR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr /
bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (:- asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_LAST PV (STRING foo) (STRING bar))))) (= MY_PN (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))) (| (COMMAND
(STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP
(BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRIN
G 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING
/ usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (:- asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_LAST PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -
))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/assoc_array.gunit b/bashast/gunit/assoc_array.gunit
index c8043af..5ac33fb 100644
--- a/bashast/gunit/assoc_array.gunit
+++ b/bashast/gunit/assoc_array.gunit
@@ -21,7 +21,7 @@ gunit bashast;
var_def:
"arr[foo]=\"asdf\"" -> (= (arr (VAR_REF foo)) (STRING (DOUBLE_QUOTED_STRING asdf)))
"arr=(a b [4]=c)" -> (= arr (ARRAY (STRING a) (STRING b) (= 4 (STRING c))))
-"asdf[$idx]=${var}" -> (= (asdf (VAR_REF idx)) (VAR_REF var))
-"asdf[++i]=${var}" -> (= (asdf (PRE_INCR (VAR_REF i))) (VAR_REF var))
-"asdf[++i,j]=${var}" -> (= (asdf (PRE_INCR (VAR_REF i)) (VAR_REF j)) (VAR_REF var))
-"asdf[$((i))]=${var}" -> (= (asdf (VAR_REF i)) (VAR_REF var))
+"asdf[$idx]=${var}" -> (= (asdf (VAR_REF idx)) (STRING (VAR_REF var)))
+"asdf[++i]=${var}" -> (= (asdf (PRE_INCR (VAR_REF i))) (STRING (VAR_REF var)))
+"asdf[++i,j]=${var}" -> (= (asdf (PRE_INCR (VAR_REF i)) (VAR_REF j)) (STRING (VAR_REF var)))
+"asdf[$((i))]=${var}" -> (= (asdf (VAR_REF i)) (STRING (VAR_REF var)))
diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit
index 4aee6d2..7ba3b5b 100644
--- a/bashast/gunit/param_main.gunit
+++ b/bashast/gunit/param_main.gunit
@@ -56,4 +56,5 @@ var_ref:
"${PV/%foo/bar}" -> (VAR_REF (REPLACE_LAST PV (STRING foo) (STRING bar)))
var_def:
-"MY_PN=${PN/asterisk-}" -> (= MY_PN (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))
+"MY_PN=${PN/asterisk-}" -> (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))
+"MY_PN=1abc" -> (= MY_PN (STRING 1 abc))
diff --git a/bashast/gunit/simp_command.gunit b/bashast/gunit/simp_command.gunit
index cd847a8..e877cab 100644
--- a/bashast/gunit/simp_command.gunit
+++ b/bashast/gunit/simp_command.gunit
@@ -20,10 +20,10 @@ gunit bashast;
simple_command:
"./command" -> (COMMAND (STRING . / command))
-"asdf=5 cat" -> (COMMAND (STRING cat) (= asdf 5))
-"asdf=5 cat out.log > result" -> (COMMAND (STRING cat) (STRING out . log) (= asdf 5) (REDIR > (STRING result)))
+"asdf=5 cat" -> (COMMAND (STRING cat) (= asdf (STRING 5)))
+"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)))
-"i=3 g=4 h=18 grep asdf" -> (COMMAND (STRING grep) (STRING asdf) (= i 3) (= g 4) (= h 18))
+"i=3 g=4 h=18 grep asdf" -> (COMMAND (STRING grep) (STRING asdf) (= i (STRING 3)) (= g (STRING 4)) (= h (STRING 18)))
"./configure --prefix=/usr/local" -> (COMMAND (STRING . / configure) (STRING - -p refix = / usr / local))
"[[while" -> (COMMAND (STRING [ [ while))
"./foobär" -> (COMMAND (STRING . / foob ä r))
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 825987a..bd11744 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -56,7 +56,7 @@ options{ k=1; }:
|NUMBER { $libbash_value = walker->get_string($NUMBER); };
var_def:
- ^(EQUALS libbash_name=name libbash_value=word){
+ ^(EQUALS libbash_name=name libbash_value=string_expr){
walker->define(libbash_name, libbash_value);
};
@@ -64,6 +64,7 @@ string_expr returns[std::string libbash_value]:
^(STRING(
(DOUBLE_QUOTED_STRING) => ^(DOUBLE_QUOTED_STRING (libbash_string=double_quoted_string { $libbash_value += libbash_string; })*)
|(ARITHMETIC_EXPRESSION) => ^(ARITHMETIC_EXPRESSION value=arithmetics { $libbash_value = boost::lexical_cast<std::string>(value); })
+ |(var_ref) => libbash_string=var_ref { $libbash_value = libbash_string; }
|libbash_string=any_string { $libbash_value = libbash_string; }
));
@@ -107,9 +108,6 @@ var_expansion returns[std::string libbash_value]:
};
word returns[std::string libbash_value]:
- // Avoid conflict with arithmetics (both have VAR_DEF)
- (var_ref) => libbash_string=var_ref { $libbash_value = libbash_string; }
- // Avoid conflict with arithmetics (both have num)
|(num) => libbash_string=num { $libbash_value = libbash_string; }
|libbash_string=string_expr { $libbash_value = libbash_string; }
|value=arithmetics { $libbash_value = boost::lexical_cast<std::string>(value); };
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-12 7:19 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-12 7:19 UTC (permalink / raw
To: gentoo-commits
commit: fa52bc79f302f87c9811e577ee8810bcdae03fc2
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Mon Apr 11 15:39:59 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Apr 12 06:23:30 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=fa52bc79
Fix produced AST for replace at start
The root node for ${var/#foo/bar} was the same as for ${var/foo/bar} now
the tokens are correct and better named.
---
bashast/bashast.g | 8 ++++----
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/param_main.gunit | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 2099bf6..8ba0400 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -52,10 +52,10 @@ tokens{
LIST;
REPLACE_FIRST;
REPLACE_ALL;
+ REPLACE_AT_START;
+ REPLACE_AT_END;
STRING;
COMMAND;
- REPLACE_FIRST;
- REPLACE_LAST;
FILE_DESCRIPTOR;
FILE_DESCRIPTOR_MOVE;
REDIR;
@@ -254,8 +254,8 @@ parameter_replace_string
: (SLASH fname|SLASH)? -> fname?;
parameter_replace_operator
: SLASH SLASH -> REPLACE_ALL
- | SLASH PCT -> REPLACE_LAST
- | SLASH POUND -> REPLACE_FIRST
+ | SLASH PCT -> REPLACE_AT_END
+ | SLASH POUND -> REPLACE_AT_START
| SLASH -> REPLACE_FIRST;
//Allowable variable names in the variable expansion
var_name: num|name|POUND;
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 317c41a..070ffdb 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP
(BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRIN
G 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING
/ usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (:- asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_LAST PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -
))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP
(BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRIN
G 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING
/ usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (:- asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING aster
isk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit
index 7ba3b5b..8bdf402 100644
--- a/bashast/gunit/param_main.gunit
+++ b/bashast/gunit/param_main.gunit
@@ -52,8 +52,8 @@ var_ref:
"$_" -> (VAR_REF _)
"${_}" -> (VAR_REF _)
"${PV//./_}" -> (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _)))
-"${PV/#foo/bar}" -> (VAR_REF (REPLACE_FIRST PV (STRING foo) (STRING bar)))
-"${PV/%foo/bar}" -> (VAR_REF (REPLACE_LAST PV (STRING foo) (STRING bar)))
+"${PV/#foo/bar}" -> (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar)))
+"${PV/%foo/bar}" -> (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar)))
var_def:
"MY_PN=${PN/asterisk-}" -> (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-17 10:58 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-17 10:58 UTC (permalink / raw
To: gentoo-commits
commit: 201cc25da63bdc1e8dad1e3589c7f1225d530e4f
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Fri Apr 15 14:48:53 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun Apr 17 10:44:32 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=201cc25d
Parser: for_expr takes in a list of expanded words
Our grammar could only handle a single word for the for expression. Now
it takes multiple and they can be all kinds of expanded things.
---
bashast/bashast.g | 2 +-
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/compound.gunit | 6 ++++--
bashast/gunit/expansions.gunit | 2 +-
bashast/gunit/simp_prog.gunit | 2 +-
5 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index a7d150c..9e02ac2 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -174,7 +174,7 @@ compound_command
| arith_comparison
| cond_comparison;
//Expressions allowed inside a compound command
-for_expr: FOR BLANK+ name (wspace IN BLANK+ word)? semiel DO wspace* clist semiel DONE -> ^(FOR name (word)? clist)
+for_expr: FOR BLANK+ name (wspace IN (BLANK+ fname)+)? semiel DO wspace* clist semiel DONE -> ^(FOR name (fname+)? clist)
| FOR BLANK* LLPAREN EOL? (BLANK* init=arithmetic BLANK*|BLANK+)? (SEMIC (BLANK? fcond=arithmetic BLANK*|BLANK+)? SEMIC|DOUBLE_SEMIC) (BLANK* mod=arithmetic)? wspace* RRPAREN semiel DO wspace clist semiel DONE
-> ^(FOR ^(FOR_INIT $init)? ^(FOR_COND $fcond)? ^(FOR_MOD $mod)? clist)
;
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index cb7fcca..a85f9c8 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo)
(STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo)
(STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND
(STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (:- asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (REPLACE_FI
RST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo)
(STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRI
NG echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail)))
(COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (:- asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (R
EPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/compound.gunit b/bashast/gunit/compound.gunit
index 4e931fd..9bf658f 100644
--- a/bashast/gunit/compound.gunit
+++ b/bashast/gunit/compound.gunit
@@ -78,8 +78,10 @@ esac" -> (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN
for_expr:
"for each in `ls |grep log`; do
echo \"file found\"
-done" -> (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
-"for each in `ls |grep log`; do echo \"file found\"; done" -> (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
+done" -> (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
+"for each in `ls |grep log`; do echo \"file found\"; done" -> (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
+"for i in 'foo' 'bar'; do echo $i; done" -> (for i (STRING (SINGLE_QUOTED_STRING foo)) (STRING (SINGLE_QUOTED_STRING bar)) (LIST (COMMAND (STRING echo) (VAR_REF i))))
+"for i in foo$var bar; do echo $i; done" -> (for i (STRING foo (VAR_REF var)) (STRING bar) (LIST (COMMAND (STRING echo) (VAR_REF i))))
"for each in `ls |grep log`; do echo file done" FAIL
"for ((5+3;5+3;5+3)); do echo yay; done" -> (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 5 3)) (FOR_MOD (+ 5 3)) (LIST (COMMAND (STRING echo) (STRING yay))))
diff --git a/bashast/gunit/expansions.gunit b/bashast/gunit/expansions.gunit
index 406d583..1ddd97b 100644
--- a/bashast/gunit/expansions.gunit
+++ b/bashast/gunit/expansions.gunit
@@ -25,5 +25,5 @@ list:
"[[ while=while ]] && echo true" -> (LIST (&& (COMPOUND_COND (KEYWORD_TEST (= (STRING while) (STRING while)))) (COMMAND (STRING echo) (STRING true))))
"for each in `ls |grep output`; do
echo $each
-done" -> (LIST (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (VAR_REF each)))))
+done" -> (LIST (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (VAR_REF each)))))
"wc <(cat /usr/share/dict/linux.words)" -> (LIST (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))))
diff --git a/bashast/gunit/simp_prog.gunit b/bashast/gunit/simp_prog.gunit
index b86c4c4..050a4d3 100644
--- a/bashast/gunit/simp_prog.gunit
+++ b/bashast/gunit/simp_prog.gunit
@@ -25,7 +25,7 @@ echo \"I found a file\"
done
echo \"finding complete\"
-"-> (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING finding file))) (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING I found a file))))) (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING finding complete))))
+"-> (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING finding file))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING I found a file))))) (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING finding complete))))
"function quit {
exit
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-17 10:58 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-17 10:58 UTC (permalink / raw
To: gentoo-commits
commit: b08bda327128213612d9d8ddad5f8b254f37b2fb
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Apr 16 11:29:40 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun Apr 17 10:44:38 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=b08bda32
Parser: no dedicated tokens for some expansions
Remove dedicated tokens for the parameter expansions dealing with
values. This keeps the lexer simpler and makes it easier to make the
colon optional.
---
bashast/bashast.g | 28 +++++++++++++++++-----------
bashast/features_script/features.sh.ast | 2 +-
bashast/features_script/features.sh.tokens | 2 +-
bashast/gunit/array.gunit | 2 +-
bashast/gunit/param_main.gunit | 2 +-
5 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 036cd3e..33b0191 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -39,8 +39,6 @@ tokens{
FOR_COND;
FOR_MOD;
FNAME;
- OFFSET;
- LIST_EXPAND;
OP;
PRE_INCR;
PRE_DECR;
@@ -50,10 +48,6 @@ tokens{
VAR_REF;
NEGATION;
LIST;
- REPLACE_FIRST;
- REPLACE_ALL;
- REPLACE_AT_START;
- REPLACE_AT_END;
STRING;
COMMAND;
FILE_DESCRIPTOR;
@@ -76,6 +70,17 @@ tokens{
COLLATING_SYMBOL;
SINGLE_QUOTED_STRING;
DOUBLE_QUOTED_STRING;
+ // parameter expansion operators
+ USE_DEFAULT;
+ USE_ALTERNATE;
+ DISPLAY_ERROR;
+ ASSIGN_DEFAULT;
+ OFFSET;
+ LIST_EXPAND;
+ REPLACE_FIRST;
+ REPLACE_ALL;
+ REPLACE_AT_START;
+ REPLACE_AT_END;
// Avoid ambiguity (being a sign or an operator)
PLUS_SIGN;
MINUS_SIGN;
@@ -244,7 +249,7 @@ var_ref
| DOLLAR MINUS -> ^(VAR_REF MINUS)
| DOLLAR BANG -> ^(VAR_REF BANG);
//Variable expansions
-var_exp : var_name (USE_DEFAULT|USE_ALTERNATE|DISPLAY_ERROR|ASSIGN_DEFAULT)^ word
+var_exp : var_name parameter_value_operator^ word
| var_name COLON wspace* os=explicit_arithmetic (COLON len=explicit_arithmetic)? -> ^(OFFSET var_name $os ^($len)?)
| BANG^ var_name_for_bang (TIMES|AT)
| BANG var_name_for_bang LSQUARE (op=TIMES|op=AT) RSQUARE -> ^(LIST_EXPAND var_name_for_bang $op)
@@ -256,6 +261,11 @@ var_exp : var_name (USE_DEFAULT|USE_ALTERNATE|DISPLAY_ERROR|ASSIGN_DEFAULT)^ wor
| var_name
| TIMES
| AT;
+parameter_value_operator
+ : COLON MINUS -> USE_DEFAULT
+ | COLON EQUALS -> ASSIGN_DEFAULT
+ | COLON QMARK -> DISPLAY_ERROR
+ | COLON PLUS -> USE_ALTERNATE;
parameter_pattern
: ((~SLASH) => parameter_pattern_part)+ -> ^(STRING parameter_pattern_part+);
parameter_pattern_part
@@ -598,10 +608,6 @@ POUNDPOUND
PCT : '%';
PCTPCT : '%%';
SLASH : '/';
-USE_DEFAULT : ':-';
-ASSIGN_DEFAULT: ':=';
-DISPLAY_ERROR: ':?';
-USE_ALTERNATE: ':+';
COLON : ':';
QMARK : '?';
//Operators for conditional statements
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index a85f9c8..645098c 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo)
(STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRI
NG echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail)))
(COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (:- asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (R
EPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo)
(STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRI
NG echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail)))
(COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (USE_DEFAULT asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (V
AR_REF (REPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/features_script/features.sh.tokens b/bashast/features_script/features.sh.tokens
index 99a04d4..bfc2bbe 100644
--- a/bashast/features_script/features.sh.tokens
+++ b/bashast/features_script/features.sh.tokens
@@ -98,7 +98,7 @@
98 NAME BLANK SLASH NAME SLASH NAME SEMIC BLANK NAME BLANK MINUS NAME PIPE NAME BLANK NAME EOL
99
100 NAME EQUALS NAME EOL
-101 DOLLAR LBRACE NAME USE_DEFAULT NAME RBRACE EOL
+101 DOLLAR LBRACE NAME COLON MINUS NAME RBRACE EOL
102 DOLLAR LBRACE NAME COLON DIGIT RBRACE EOL
103 DOLLAR LBRACE BANG NAME TIMES RBRACE EOL
104 DOLLAR LBRACE BANG NAME AT RBRACE EOL
diff --git a/bashast/gunit/array.gunit b/bashast/gunit/array.gunit
index ae5ad6d..b8517ed 100644
--- a/bashast/gunit/array.gunit
+++ b/bashast/gunit/array.gunit
@@ -25,7 +25,7 @@ var_def:
var_ref:
"$asdf" -> (VAR_REF asdf)
-"${asdf[0]:-default}" -> (VAR_REF (:- (asdf 0) (STRING default)))
+"${asdf[0]:-default}" -> (VAR_REF (USE_DEFAULT (asdf 0) (STRING default)))
"${asdf[3]}" -> (VAR_REF (asdf 3))
"${asdf[4] }" -> (VAR_REF (asdf 4))
"${asdf[i*2]}" -> (VAR_REF (asdf (* (VAR_REF i) 2))))
diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit
index 7394b66..6c70077 100644
--- a/bashast/gunit/param_main.gunit
+++ b/bashast/gunit/param_main.gunit
@@ -21,7 +21,7 @@ gunit bashast;
var_ref:
"$asdf" -> (VAR_REF asdf)
"${asdf}" -> (VAR_REF asdf)
-"${asdf:-foo}" -> (VAR_REF (:- asdf (STRING foo)))
+"${asdf:-foo}" -> (VAR_REF (USE_DEFAULT asdf (STRING foo)))
"${bar:7}" -> (VAR_REF (OFFSET bar 7))
"${bar: -10}" -> (VAR_REF (OFFSET bar (MINUS_SIGN 10)))
"${bar:(-10 + 5)}" -> (VAR_REF (OFFSET bar (+ (MINUS_SIGN 10) 5)))
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-17 10:58 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-17 10:58 UTC (permalink / raw
To: gentoo-commits
commit: 4299999e3ac1b881484db6fb9795dd3da66a17b5
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Apr 16 11:56:33 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun Apr 17 10:44:40 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=4299999e
Parser: fix multiple variable expansions in an arg
The parser now properly supports things like dodir ${foo}/${bar}. This
was fixed by not special casing variable references and command
substitutions. The AST is a little noisier now but if that's a problem
then it can be simplified later.
---
bashast/bashast.g | 9 +--------
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/brace.gunit | 2 +-
bashast/gunit/compound.gunit | 4 ++--
bashast/gunit/expansions.gunit | 2 +-
bashast/gunit/simp_command.gunit | 1 +
6 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index f67013e..9619d64 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -124,14 +124,7 @@ simple_command
variable_definitions
: var_def (BLANK!+ var_def)*;
bash_command
- : fname_no_res_word (BLANK+ arg)* -> ^(COMMAND fname_no_res_word arg*);
-//An argument to a command
-//fname can also match var_ref and command_sub but that gives a noisier AST
-arg
-options{backtrack=false;}
- : (var_ref) => var_ref
- | (command_sub) => command_sub
- | fname;
+ : fname_no_res_word (BLANK+ fname)* -> ^(COMMAND fname_no_res_word fname*);
redirect: BLANK!* here_string_op^ BLANK!* fname
| BLANK!* here_doc_op^ BLANK!* fname EOL! heredoc
| BLANK* redir_op BLANK* redir_dest -> ^(REDIR redir_op redir_dest)
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 23ac261..62a969c 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo)
(STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRI
NG echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail)))
(COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar)))))
(= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COM
MAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING outp
ut)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (S
TRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REP
LACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/brace.gunit b/bashast/gunit/brace.gunit
index 937e594..2030d58 100644
--- a/bashast/gunit/brace.gunit
+++ b/bashast/gunit/brace.gunit
@@ -24,7 +24,7 @@ brace_expansion:
"{a..d}" -> (BRACE_EXP (.. a d))
"{{a,b},c,d}" -> (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d))
-arg:
+fname:
"a{b,c}" -> (STRING a (BRACE_EXP (STRING b) (STRING c)))
"{c..d}f" -> (STRING (BRACE_EXP (.. c d)) f)
"a{a,b}b{c,d}" -> (STRING a (BRACE_EXP (STRING a) (STRING b)) b (BRACE_EXP (STRING c) (STRING d)))
diff --git a/bashast/gunit/compound.gunit b/bashast/gunit/compound.gunit
index 9bf658f..587d869 100644
--- a/bashast/gunit/compound.gunit
+++ b/bashast/gunit/compound.gunit
@@ -80,8 +80,8 @@ for_expr:
echo \"file found\"
done" -> (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
"for each in `ls |grep log`; do echo \"file found\"; done" -> (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
-"for i in 'foo' 'bar'; do echo $i; done" -> (for i (STRING (SINGLE_QUOTED_STRING foo)) (STRING (SINGLE_QUOTED_STRING bar)) (LIST (COMMAND (STRING echo) (VAR_REF i))))
-"for i in foo$var bar; do echo $i; done" -> (for i (STRING foo (VAR_REF var)) (STRING bar) (LIST (COMMAND (STRING echo) (VAR_REF i))))
+"for i in 'foo' 'bar'; do echo $i; done" -> (for i (STRING (SINGLE_QUOTED_STRING foo)) (STRING (SINGLE_QUOTED_STRING bar)) (LIST (COMMAND (STRING echo) (STRING (VAR_REF i)))))
+"for i in foo$var bar; do echo $i; done" -> (for i (STRING foo (VAR_REF var)) (STRING bar) (LIST (COMMAND (STRING echo) (STRING (VAR_REF i)))))
"for each in `ls |grep log`; do echo file done" FAIL
"for ((5+3;5+3;5+3)); do echo yay; done" -> (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 5 3)) (FOR_MOD (+ 5 3)) (LIST (COMMAND (STRING echo) (STRING yay))))
diff --git a/bashast/gunit/expansions.gunit b/bashast/gunit/expansions.gunit
index 1ddd97b..4ea5924 100644
--- a/bashast/gunit/expansions.gunit
+++ b/bashast/gunit/expansions.gunit
@@ -25,5 +25,5 @@ list:
"[[ while=while ]] && echo true" -> (LIST (&& (COMPOUND_COND (KEYWORD_TEST (= (STRING while) (STRING while)))) (COMMAND (STRING echo) (STRING true))))
"for each in `ls |grep output`; do
echo $each
-done" -> (LIST (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (VAR_REF each)))))
+done" -> (LIST (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))))))
"wc <(cat /usr/share/dict/linux.words)" -> (LIST (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))))
diff --git a/bashast/gunit/simp_command.gunit b/bashast/gunit/simp_command.gunit
index e877cab..b2dc74a 100644
--- a/bashast/gunit/simp_command.gunit
+++ b/bashast/gunit/simp_command.gunit
@@ -28,3 +28,4 @@ simple_command:
"[[while" -> (COMMAND (STRING [ [ while))
"./foobär" -> (COMMAND (STRING . / foob ä r))
"cat ~/Documents/todo.txt" -> (COMMAND (STRING cat) (STRING ~ / Documents / todo . txt))
+"dodir ${foo}/${bar}" -> (COMMAND (STRING dodir) (STRING (VAR_REF foo) / (VAR_REF bar)))
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-17 10:58 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-17 10:58 UTC (permalink / raw
To: gentoo-commits
commit: f4245766c827b57912d1fdab970f6280bfad03fc
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Apr 16 11:39:38 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun Apr 17 10:44:40 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=f4245766
Parser: optional colon in parameter expansions
In the value related expansions the colon is optional. When there's no
colon it's only tested that the parameter is unset.
---
bashast/bashast.g | 24 ++++++++++++++++--------
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/array.gunit | 2 +-
bashast/gunit/param_main.gunit | 3 ++-
bashast/libbashWalker.g | 6 +++---
5 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 33b0191..f67013e 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -71,10 +71,14 @@ tokens{
SINGLE_QUOTED_STRING;
DOUBLE_QUOTED_STRING;
// parameter expansion operators
- USE_DEFAULT;
- USE_ALTERNATE;
- DISPLAY_ERROR;
- ASSIGN_DEFAULT;
+ USE_DEFAULT_WHEN_UNSET;
+ USE_ALTERNATE_WHEN_UNSET;
+ DISPLAY_ERROR_WHEN_UNSET;
+ ASSIGN_DEFAULT_WHEN_UNSET;
+ USE_DEFAULT_WHEN_UNSET_OR_NULL;
+ USE_ALTERNATE_WHEN_UNSET_OR_NULL;
+ DISPLAY_ERROR_WHEN_UNSET_OR_NULL;
+ ASSIGN_DEFAULT_WHEN_UNSET_OR_NULL;
OFFSET;
LIST_EXPAND;
REPLACE_FIRST;
@@ -262,10 +266,14 @@ var_exp : var_name parameter_value_operator^ word
| TIMES
| AT;
parameter_value_operator
- : COLON MINUS -> USE_DEFAULT
- | COLON EQUALS -> ASSIGN_DEFAULT
- | COLON QMARK -> DISPLAY_ERROR
- | COLON PLUS -> USE_ALTERNATE;
+ : COLON MINUS -> USE_DEFAULT_WHEN_UNSET_OR_NULL
+ | COLON EQUALS -> ASSIGN_DEFAULT_WHEN_UNSET_OR_NULL
+ | COLON QMARK -> DISPLAY_ERROR_WHEN_UNSET_OR_NULL
+ | COLON PLUS -> USE_ALTERNATE_WHEN_UNSET_OR_NULL
+ | MINUS -> USE_DEFAULT_WHEN_UNSET
+ | EQUALS -> ASSIGN_DEFAULT_WHEN_UNSET
+ | QMARK -> DISPLAY_ERROR_WHEN_UNSET
+ | PLUS -> USE_ALTERNATE_WHEN_UNSET;
parameter_pattern
: ((~SLASH) => parameter_pattern_part)+ -> ^(STRING parameter_pattern_part+);
parameter_pattern_part
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 645098c..23ac261 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo)
(STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRI
NG echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail)))
(COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (USE_DEFAULT asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (V
AR_REF (REPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (VAR_REF failedtests))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (VAR_REF (asdf 3))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo)
(STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (VAR_REF each)) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRI
NG echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail)))
(COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (VAR_REF @) (VAR_REF *)) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar)))))
(= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/array.gunit b/bashast/gunit/array.gunit
index b8517ed..d44217c 100644
--- a/bashast/gunit/array.gunit
+++ b/bashast/gunit/array.gunit
@@ -25,7 +25,7 @@ var_def:
var_ref:
"$asdf" -> (VAR_REF asdf)
-"${asdf[0]:-default}" -> (VAR_REF (USE_DEFAULT (asdf 0) (STRING default)))
+"${asdf[0]:-default}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL (asdf 0) (STRING default)))
"${asdf[3]}" -> (VAR_REF (asdf 3))
"${asdf[4] }" -> (VAR_REF (asdf 4))
"${asdf[i*2]}" -> (VAR_REF (asdf (* (VAR_REF i) 2))))
diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit
index 6c70077..1a68e5e 100644
--- a/bashast/gunit/param_main.gunit
+++ b/bashast/gunit/param_main.gunit
@@ -21,7 +21,8 @@ gunit bashast;
var_ref:
"$asdf" -> (VAR_REF asdf)
"${asdf}" -> (VAR_REF asdf)
-"${asdf:-foo}" -> (VAR_REF (USE_DEFAULT asdf (STRING foo)))
+"${asdf:-foo}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo)))
+"${asdf='foo'}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET asdf (STRING (SINGLE_QUOTED_STRING foo))))
"${bar:7}" -> (VAR_REF (OFFSET bar 7))
"${bar: -10}" -> (VAR_REF (OFFSET bar (MINUS_SIGN 10)))
"${bar:(-10 + 5)}" -> (VAR_REF (OFFSET bar (+ (MINUS_SIGN 10) 5)))
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 05c1127..b29dcf5 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -137,13 +137,13 @@ var_name returns[std::string libbash_value, unsigned index]
};
var_expansion returns[std::string libbash_value]:
- ^(USE_DEFAULT var_name libbash_word=word) {
+ ^(USE_DEFAULT_WHEN_UNSET_OR_NULL var_name libbash_word=word) {
libbash_value = walker->do_default_expansion($var_name.libbash_value, libbash_word, $var_name.index);
}
- |^(ASSIGN_DEFAULT var_name libbash_word=word) {
+ |^(ASSIGN_DEFAULT_WHEN_UNSET_OR_NULL var_name libbash_word=word) {
libbash_value = walker->do_assign_expansion($var_name.libbash_value, libbash_word, $var_name.index);
}
- |^(USE_ALTERNATE var_name libbash_word=word) {
+ |^(USE_ALTERNATE_WHEN_UNSET_OR_NULL var_name libbash_word=word) {
libbash_value = walker->do_alternate_expansion($var_name.libbash_value, libbash_word, $var_name.index);
}
|(^(OFFSET var_name arithmetics arithmetics)) => ^(OFFSET var_name offset=arithmetics length=arithmetics) {
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-17 10:58 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-17 10:58 UTC (permalink / raw
To: gentoo-commits
commit: c0da1e1a93d0a8eb6b06a5f82527ce404eac1732
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Apr 16 14:04:56 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun Apr 17 10:57:03 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=c0da1e1a
Parser: rename currshell to current_shell
---
bashast/bashast.g | 8 ++++----
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/compound.gunit | 8 ++++----
bashast/gunit/function.gunit | 14 +++++++-------
bashast/gunit/simp_prog.gunit | 2 +-
5 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 30af37d..7939229 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -33,7 +33,7 @@ tokens{
COMMAND_SUB;
CASE_PATTERN;
SUBSHELL;
- CURRSHELL;
+ CURRENT_SHELL;
COMPOUND_ARITH;
COMPOUND_COND;
FOR_INIT;
@@ -178,7 +178,7 @@ compound_command
| until_expr
| case_expr
| subshell
- | currshell
+ | current_shell
| arith_comparison
| cond_comparison;
//Expressions allowed inside a compound command
@@ -214,8 +214,8 @@ case_pattern
//A grouping of commands executed in a subshell
subshell: LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAREN -> ^(SUBSHELL clist);
//A grouping of commands executed in the current shell
-currshell
- : LBRACE wspace clist semiel wspace* RBRACE -> ^(CURRSHELL clist);
+current_shell
+ : LBRACE wspace clist semiel wspace* RBRACE -> ^(CURRENT_SHELL clist);
//comparison using arithmetic
arith_comparison
: LLPAREN wspace? arithmetic wspace? RRPAREN -> ^(COMPOUND_ARITH arithmetic);
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 62a969c..5adc56b 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function lots_o_echo (CURRSHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function do_some_arith (CURRSHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COM
MAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING outp
ut)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (S
TRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REP
LACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function lots_o_echo (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function do_some_arith (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)
))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STR
ING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (CO
MMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_
REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/compound.gunit b/bashast/gunit/compound.gunit
index dfdacc5..d36d5f9 100644
--- a/bashast/gunit/compound.gunit
+++ b/bashast/gunit/compound.gunit
@@ -32,15 +32,15 @@ arith_comparison:
"((5+3))" -> (COMPOUND_ARITH (+ 5 3))
"(( 5+3 ))" -> (COMPOUND_ARITH (+ 5 3))
-currshell:
-"{ time cat; }" -> (CURRSHELL (LIST (COMMAND (STRING cat) time)))
+current_shell:
+"{ time cat; }" -> (CURRENT_SHELL (LIST (COMMAND (STRING cat) time)))
"{ time cat
-}" -> (CURRSHELL (LIST (COMMAND (STRING cat) time)))
+}" -> (CURRENT_SHELL (LIST (COMMAND (STRING cat) time)))
// there's a tab on the empty line
"{
echo
-}" -> (CURRSHELL (LIST (COMMAND (STRING echo))))
+}" -> (CURRENT_SHELL (LIST (COMMAND (STRING echo))))
"{time cat}" FAIL
"{ time cat }" FAIL
diff --git a/bashast/gunit/function.gunit b/bashast/gunit/function.gunit
index 157c0a6..1cd99ac 100644
--- a/bashast/gunit/function.gunit
+++ b/bashast/gunit/function.gunit
@@ -21,18 +21,18 @@ gunit bashast;
function:
"function quit {
exit
-}" -> (function quit (CURRSHELL (LIST (COMMAND (STRING exit)))))
+}" -> (function quit (CURRENT_SHELL (LIST (COMMAND (STRING exit)))))
"function quit{ exit; }" FAIL
"function quit { exit }" FAIL
"function 'foo' { exit; }" FAIL
-"function quit { exit; }" -> (function quit (CURRSHELL (LIST (COMMAND (STRING exit)))))
-"function foo() { :; }" -> (function foo (CURRSHELL (LIST (COMMAND (STRING :)))))
-"foo() { :; }" -> (function foo (CURRSHELL (LIST (COMMAND (STRING :)))))
+"function quit { exit; }" -> (function quit (CURRENT_SHELL (LIST (COMMAND (STRING exit)))))
+"function foo() { :; }" -> (function foo (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
+"foo() { :; }" -> (function foo (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
-"function quit { exit; } > /dev/null" -> (function quit (CURRSHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null)))
+"function quit { exit; } > /dev/null" -> (function quit (CURRENT_SHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null)))
"function quit {
# comment
- exit; } > /dev/null" -> (function quit (CURRSHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null)))
-"function help { echo hi; } 2> /dev/null" -> (function help (CURRSHELL (LIST (COMMAND (STRING echo) (STRING hi)))) (REDIR 2 > (STRING / dev / null)))
+ exit; } > /dev/null" -> (function quit (CURRENT_SHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null)))
+"function help { echo hi; } 2> /dev/null" -> (function help (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi)))) (REDIR 2 > (STRING / dev / null)))
"function help { echo 3; } 2> /dev/null > output" OK
diff --git a/bashast/gunit/simp_prog.gunit b/bashast/gunit/simp_prog.gunit
index 050a4d3..25a9119 100644
--- a/bashast/gunit/simp_prog.gunit
+++ b/bashast/gunit/simp_prog.gunit
@@ -35,4 +35,4 @@ hello () {
}
hello
quit
-echo foo" -> (LIST (function quit (CURRSHELL (LIST (COMMAND (STRING exit))))) (function hello (CURRSHELL (LIST (COMMAND (STRING echo) (STRING Hello !))))) (COMMAND (STRING hello)) (COMMAND (STRING quit)) (COMMAND (STRING echo) (STRING foo)))
+echo foo" -> (LIST (function quit (CURRENT_SHELL (LIST (COMMAND (STRING exit))))) (function hello (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING Hello !))))) (COMMAND (STRING hello)) (COMMAND (STRING quit)) (COMMAND (STRING echo) (STRING foo)))
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-17 10:58 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-17 10:58 UTC (permalink / raw
To: gentoo-commits
commit: 12b5f73629882ff6e3268f383c0ced63f6cbbefa
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Apr 16 17:04:52 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun Apr 17 10:57:04 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=12b5f736
Parser: support hyphens in function names
Function names are not as strict as man bash states. We are now allow
hyphens because that's used in ebuilds. Let's try to be as strict as
tree usage allows.
---
bashast/bashast.g | 8 ++++++--
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/function.gunit | 15 ++++++++-------
bashast/gunit/simp_prog.gunit | 2 +-
4 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index d82e7cf..db04b03 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -520,8 +520,12 @@ arithmetic_assignment
process_substitution
: (dir=LESS_THAN|dir=GREATER_THAN)LPAREN clist BLANK* RPAREN -> ^(PROCESS_SUBSTITUTION $dir clist);
//the biggie: functions
-function: FUNCTION BLANK+ name (BLANK* parens)? wspace compound_command redirect* -> ^(FUNCTION name compound_command redirect*)
- | name BLANK* parens wspace compound_command redirect* -> ^(FUNCTION["function"] name compound_command redirect*);
+function: FUNCTION BLANK+ function_name (BLANK* parens)? wspace compound_command redirect* -> ^(FUNCTION ^(STRING function_name) compound_command redirect*)
+ | function_name BLANK* parens wspace compound_command redirect* -> ^(FUNCTION["function"] ^(STRING function_name) compound_command redirect*);
+//http://article.gmane.org/gmane.comp.shells.bash.bugs/16424
+//the documented set is stricter but we need to have at least what's used in Gentoo
+function_name
+ : (MINUS|name)+;
parens : LPAREN BLANK* RPAREN;
name : NAME
| LETTER
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 5adc56b..2e1b91e 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function lots_o_echo (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function do_some_arith (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function arrays (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)
))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STR
ING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (CO
MMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_
REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo)
(STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls))
(COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND
(STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar)
)))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/function.gunit b/bashast/gunit/function.gunit
index 1cd99ac..b233b0a 100644
--- a/bashast/gunit/function.gunit
+++ b/bashast/gunit/function.gunit
@@ -21,18 +21,19 @@ gunit bashast;
function:
"function quit {
exit
-}" -> (function quit (CURRENT_SHELL (LIST (COMMAND (STRING exit)))))
+}" -> (function (STRING quit) (CURRENT_SHELL (LIST (COMMAND (STRING exit)))))
"function quit{ exit; }" FAIL
"function quit { exit }" FAIL
"function 'foo' { exit; }" FAIL
-"function quit { exit; }" -> (function quit (CURRENT_SHELL (LIST (COMMAND (STRING exit)))))
-"function foo() { :; }" -> (function foo (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
-"foo() { :; }" -> (function foo (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
+"function quit { exit; }" -> (function (STRING quit) (CURRENT_SHELL (LIST (COMMAND (STRING exit)))))
+"function foo() { :; }" -> (function (STRING foo) (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
+"foo() { :; }" -> (function (STRING foo) (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
-"function quit { exit; } > /dev/null" -> (function quit (CURRENT_SHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null)))
+"function quit { exit; } > /dev/null" -> (function (STRING quit) (CURRENT_SHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null)))
"function quit {
# comment
- exit; } > /dev/null" -> (function quit (CURRENT_SHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null)))
-"function help { echo hi; } 2> /dev/null" -> (function help (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi)))) (REDIR 2 > (STRING / dev / null)))
+ exit; } > /dev/null" -> (function (STRING quit) (CURRENT_SHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null)))
+"function help { echo hi; } 2> /dev/null" -> (function (STRING help) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi)))) (REDIR 2 > (STRING / dev / null)))
"function help { echo 3; } 2> /dev/null > output" OK
+"foo-bar() { :; }" -> (function (STRING foo - bar) (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
diff --git a/bashast/gunit/simp_prog.gunit b/bashast/gunit/simp_prog.gunit
index 25a9119..87d26b8 100644
--- a/bashast/gunit/simp_prog.gunit
+++ b/bashast/gunit/simp_prog.gunit
@@ -35,4 +35,4 @@ hello () {
}
hello
quit
-echo foo" -> (LIST (function quit (CURRENT_SHELL (LIST (COMMAND (STRING exit))))) (function hello (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING Hello !))))) (COMMAND (STRING hello)) (COMMAND (STRING quit)) (COMMAND (STRING echo) (STRING foo)))
+echo foo" -> (LIST (function (STRING quit) (CURRENT_SHELL (LIST (COMMAND (STRING exit))))) (function (STRING hello) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING Hello !))))) (COMMAND (STRING hello)) (COMMAND (STRING quit)) (COMMAND (STRING echo) (STRING foo)))
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-17 10:58 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-17 10:58 UTC (permalink / raw
To: gentoo-commits
commit: 9cbc10ff010924392a224544a9caee5b17806a5b
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Apr 16 22:04:59 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun Apr 17 10:57:04 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=9cbc10ff
Parser: fix multiple roots in pipeline rule
If you had multiple variable declarations on a single row the pipeline
rule tried to use multiple nodes as the root. This is now fixed via
using the VARIABLE_DEFINITIONS virtual token to group the assignments.
With this change ast_printer -nsf /usr/portage/eclass/*.eclass produces
no error messages. This of course is no guarantee of correct parsing.
---
bashast/bashast.g | 3 ++-
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/list.gunit | 4 ++--
bashast/gunit/pipeline.gunit | 1 +
bashast/libbashWalker.g | 4 +++-
5 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index ade30a9..d0b9926 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -71,6 +71,7 @@ tokens{
COLLATING_SYMBOL;
SINGLE_QUOTED_STRING;
DOUBLE_QUOTED_STRING;
+ VARIABLE_DEFINITIONS;
// parameter expansion operators
USE_DEFAULT_WHEN_UNSET;
USE_ALTERNATE_WHEN_UNSET;
@@ -120,7 +121,7 @@ command
//Simple bash commands
simple_command
: variable_definitions BLANK!+ bash_command^ redirect*
- | variable_definitions
+ | variable_definitions -> ^(VARIABLE_DEFINITIONS variable_definitions)
| bash_command^ redirect*;
variable_definitions
: var_def (BLANK!+ var_def)*;
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 2e1b91e..de32507 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d))) (= (arr (VAR_REF foo)) (STRING 3)) (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo)
(STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls))
(COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND
(STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (= asdf (STRING parameters)) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar)
)))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))
) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIS
T (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STR
ING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF
(REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/list.gunit b/bashast/gunit/list.gunit
index c434032..42836ca 100644
--- a/bashast/gunit/list.gunit
+++ b/bashast/gunit/list.gunit
@@ -36,8 +36,8 @@ cp arch/x86_64/boot/bzImage /boot/kernel" -> (LIST (COMMAND (STRING make)) (COMM
"a=asdf
b=three
-echo \"a b\"" -> (LIST (= a (STRING asdf)) (= b (STRING three)) (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING a b))))
+echo \"a b\"" -> (LIST (VARIABLE_DEFINITIONS (= a (STRING asdf))) (VARIABLE_DEFINITIONS (= b (STRING three))) (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING a b))))
"echo one && (echo two || echo three)" -> (LIST (&& (COMMAND (STRING echo) (STRING one)) (SUBSHELL (LIST (|| (COMMAND (STRING echo) (STRING two)) (COMMAND (STRING echo) (STRING three)))))))
-"FOO='bar' ;" -> (LIST (= FOO (STRING (SINGLE_QUOTED_STRING bar))))
+"FOO='bar' ;" -> (LIST (VARIABLE_DEFINITIONS (= FOO (STRING (SINGLE_QUOTED_STRING bar)))))
"true;
true" -> (LIST (COMMAND (STRING true)) (COMMAND (STRING true)))
diff --git a/bashast/gunit/pipeline.gunit b/bashast/gunit/pipeline.gunit
index 7d69527..f922ca5 100644
--- a/bashast/gunit/pipeline.gunit
+++ b/bashast/gunit/pipeline.gunit
@@ -29,3 +29,4 @@ pipeline:
"if time cat; then
echo \"three\"
fi" -> (if (LIST (COMMAND (STRING cat) time)) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING three)))))
+"i=1 j=2" -> (VARIABLE_DEFINITIONS (= i (STRING 1)) (= j (STRING 2)))
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index b29dcf5..7702b36 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -62,7 +62,9 @@ inline void set_index(const std::string& name, unsigned& index, int value)
start: list|EOF;
-list: ^(LIST var_def+);
+list: ^(LIST variable_definitions+);
+
+variable_definitions: ^(VARIABLE_DEFINITIONS var_def+);
name_base returns[std::string libbash_value]:
NAME {$libbash_value = walker->get_string($NAME);}
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-20 11:26 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-20 11:26 UTC (permalink / raw
To: gentoo-commits
commit: 299530824de456012c74a810e4943f86e375a5a5
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Tue Apr 19 20:55:01 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 11:22:49 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=29953082
Parser: functions inside command substitution
Command substitution is not fixed to one simple pipeline. We now
support arbitrary bash syntax inside command substitution.
---
bashast/bashast.g | 4 ++--
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/array.gunit | 2 +-
bashast/gunit/command_sub.gunit | 8 ++++----
bashast/gunit/compound.gunit | 16 ++++++++--------
bashast/gunit/expansions.gunit | 2 +-
bashast/gunit/fname.gunit | 4 ++--
bashast/gunit/simp_prog.gunit | 2 +-
8 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 0dc931f..ffa67f6 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -166,8 +166,8 @@ brace_expansion_part
| -> EMPTY_BRACE_EXPANSION_ATOM;
commasep: brace_expansion_part(COMMA! brace_expansion_part)+;
command_sub
- : DOLLAR LPAREN pipeline BLANK? RPAREN -> ^(COMMAND_SUB pipeline)
- | TICK pipeline BLANK? TICK -> ^(COMMAND_SUB pipeline) ;
+ : DOLLAR LPAREN clist BLANK? RPAREN -> ^(COMMAND_SUB clist)
+ | TICK clist BLANK? TICK -> ^(COMMAND_SUB clist) ;
//compound commands
compound_command
: for_expr
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index de32507..44c5e39 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))
) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING foobar))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (FOR_MOD (+ 3 1)) (LIS
T (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STR
ING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF
(REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c
)))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (for (FOR_INIT (+ 5 3)) (FOR_COND (+
6 2)) (FOR_MOD (+ 3 1)) (LIST (COMMAND (STRING echo) (STRING yay)))) (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words
))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (# asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (## asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (% asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR
_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/array.gunit b/bashast/gunit/array.gunit
index 402e707..8edf03d 100644
--- a/bashast/gunit/array.gunit
+++ b/bashast/gunit/array.gunit
@@ -20,7 +20,7 @@ gunit bashast;
var_def:
"asdf=(a b c d)"->(= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))
-"asdf=(`echo 6` b c d)"->(= asdf (ARRAY (STRING (COMMAND_SUB (COMMAND (STRING echo) (STRING 6)))) (STRING b) (STRING c) (STRING d)))
+"asdf=(`echo 6` b c d)"-> (= asdf (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))
"asdf=(${P} b c d)"->(= asdf (ARRAY (STRING (VAR_REF P)) (STRING b) (STRING c) (STRING d)))
"asdf=(
--disable-dependency-tracking
diff --git a/bashast/gunit/command_sub.gunit b/bashast/gunit/command_sub.gunit
index 1bf481a..6cf07de 100644
--- a/bashast/gunit/command_sub.gunit
+++ b/bashast/gunit/command_sub.gunit
@@ -19,7 +19,7 @@
gunit bashast;
command_sub:
-"$(echo \"foo\")" -> (COMMAND_SUB (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING foo))))
-"$(ls |grep file)" -> (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING file))))
-"`cat output.log |grep error|cut`" -> (COMMAND_SUB (| (| (COMMAND (STRING cat) (STRING output . log)) (COMMAND (STRING grep) (STRING error))) (COMMAND (STRING cut))))
-
+"$(echo \"foo\")" -> (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING foo)))))
+"$(ls |grep file)" -> (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING file)))))
+"`cat output.log |grep error|cut`" -> (COMMAND_SUB (LIST (| (| (COMMAND (STRING cat) (STRING output . log)) (COMMAND (STRING grep) (STRING error))) (COMMAND (STRING cut)))))
+"$(function foo() { echo 'hello'; }; foo)" -> (COMMAND_SUB (LIST (function (STRING foo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING hello)))))) (COMMAND (STRING foo))))
diff --git a/bashast/gunit/compound.gunit b/bashast/gunit/compound.gunit
index d36d5f9..f999b44 100644
--- a/bashast/gunit/compound.gunit
+++ b/bashast/gunit/compound.gunit
@@ -54,7 +54,7 @@ subshell:
case_expr:
"case a in esac" -> (case (STRING a))
"case `echo asdf` in
-esac" -> (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))))
+esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))))
"case `echo asdf` in
gz)
@@ -65,7 +65,7 @@ echo three
;;
*) echo woo
;;
-esac" -> (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo)))))
+esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo)))))
"case `echo asdf` in
gz)
@@ -75,16 +75,16 @@ esac" -> (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN
echo three
;;
*) echo woo
-esac" -> (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo)))))
+esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo)))))
"case `echo asdf` in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo esac" FAIL
-"case `echo asdf` in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo ;; esac" -> (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (STRING asdf) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo)))))
+"case `echo asdf` in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo ;; esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) (STRING asdf) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo)))))
for_expr:
"for each in `ls |grep log`; do
echo \"file found\"
-done" -> (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
-"for each in `ls |grep log`; do echo \"file found\"; done" -> (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
+done" -> (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
+"for each in `ls |grep log`; do echo \"file found\"; done" -> (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
"for i in 'foo' 'bar'; do echo $i; done" -> (for i (STRING (SINGLE_QUOTED_STRING foo)) (STRING (SINGLE_QUOTED_STRING bar)) (LIST (COMMAND (STRING echo) (STRING (VAR_REF i)))))
"for i in foo$var bar; do echo $i; done" -> (for i (STRING foo (VAR_REF var)) (STRING bar) (LIST (COMMAND (STRING echo) (STRING (VAR_REF i)))))
"for each in `ls |grep log`; do echo file done" FAIL
@@ -98,8 +98,8 @@ done" -> (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRIN
sel_expr:
"select each in `ls |grep log`; do
echo \"file found\"
- done" -> (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
-"select each in `ls |grep log`; do echo \"file found\"; done" -> (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
+ done" -> (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
+"select each in `ls |grep log`; do echo \"file found\"; done" -> (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
"select each in `ls |grep log`; do echo file done" FAIL
if_expr:
diff --git a/bashast/gunit/expansions.gunit b/bashast/gunit/expansions.gunit
index bbfa37a..17436e8 100644
--- a/bashast/gunit/expansions.gunit
+++ b/bashast/gunit/expansions.gunit
@@ -25,5 +25,5 @@ clist:
"[[ while=while ]] && echo true" -> (LIST (&& (COMPOUND_COND (KEYWORD_TEST (= (STRING while) (STRING while)))) (COMMAND (STRING echo) (STRING true))))
"for each in `ls |grep output`; do
echo $each
-done" -> (LIST (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))))))
+done" -> (LIST (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))))))
"wc <(cat /usr/share/dict/linux.words)" -> (LIST (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))))
diff --git a/bashast/gunit/fname.gunit b/bashast/gunit/fname.gunit
index f048755..467bd43 100644
--- a/bashast/gunit/fname.gunit
+++ b/bashast/gunit/fname.gunit
@@ -25,8 +25,8 @@ fname:
"\"\"" -> (STRING DOUBLE_QUOTED_STRING)
"\"For more info on this patchset, and how to report problems, see:\"" -> (STRING (DOUBLE_QUOTED_STRING For more info on this patchset , and how to report problems , see :))
"\"asdf;!\"" -> (STRING (DOUBLE_QUOTED_STRING asdf ; !))
-"\"$(whoami)\"" -> (STRING (DOUBLE_QUOTED_STRING (COMMAND_SUB (COMMAND (STRING whoami)))))
-"\"`whoami`\"" -> (STRING (DOUBLE_QUOTED_STRING (COMMAND_SUB (COMMAND (STRING whoami)))))
+"\"$(whoami)\"" -> (STRING (DOUBLE_QUOTED_STRING (COMMAND_SUB (LIST (COMMAND (STRING whoami))))))
+"\"`whoami`\"" -> (STRING (DOUBLE_QUOTED_STRING (COMMAND_SUB (LIST (COMMAND (STRING whoami))))))
"'`whoami`'" -> (STRING (SINGLE_QUOTED_STRING ` whoami `))
"'$(whoami)'" -> (STRING (SINGLE_QUOTED_STRING $ ( whoami )))
"\"${P}\"" -> (STRING (DOUBLE_QUOTED_STRING (VAR_REF P)))
diff --git a/bashast/gunit/simp_prog.gunit b/bashast/gunit/simp_prog.gunit
index 87d26b8..ebde3ed 100644
--- a/bashast/gunit/simp_prog.gunit
+++ b/bashast/gunit/simp_prog.gunit
@@ -25,7 +25,7 @@ echo \"I found a file\"
done
echo \"finding complete\"
-"-> (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING finding file))) (for each (STRING (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING I found a file))))) (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING finding complete))))
+"-> (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING finding file))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING I found a file))))) (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING finding complete))))
"function quit {
exit
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-04-27 15:11 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-04-27 15:11 UTC (permalink / raw
To: gentoo-commits
commit: fbbd26979d27cb9ac33aa131ca8076dd9a683cb8
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 27 14:52:16 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 27 14:58:43 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=fbbd2697
Parser: simplify and fix cond_part rule
We don't have to use so many alternatives in cond_part because
fname will cover all that. Reserved word shouldn't be treated
specially.
---
bashast/bashast.g | 9 ++-------
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/cond_main.gunit | 2 +-
bashast/gunit/expansions.gunit | 3 ++-
4 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 7d44917..9fcacc0 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -365,11 +365,7 @@ unary_cond
uop : MINUS! LETTER;
//Allowable parts of conditions
cond_part: brace_expansion
- | var_ref
- | res_word_str -> ^(STRING res_word_str)
- | num
- | fname
- | arithmetic;
+ | fname;
//Rules for whitespace/line endings
wspace : BLANK+|EOL+;
semiel : BLANK* (SEMIC|EOL) BLANK*;
@@ -652,8 +648,7 @@ COLON : ':';
QMARK : '?';
//Operators for conditional statements
TEST_EXPR : 'test';
-LOGICAND
- : '&&';
+LOGICAND : '&&';
LOGICOR : '||';
//Tokens for strings
CONTINUE_LINE
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index dcc435a..54f701c 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c
)))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+
6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1))) (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq 5 6)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . word
s))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF
1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c
)))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+
6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1))) (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / d
ict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND
(STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/cond_main.gunit b/bashast/gunit/cond_main.gunit
index b40322d..159c734 100644
--- a/bashast/gunit/cond_main.gunit
+++ b/bashast/gunit/cond_main.gunit
@@ -21,7 +21,7 @@ gunit bashast;
cond_expr:
"[[ -a this/is.afile ]]" -> (KEYWORD_TEST (a (STRING this / is . afile)))
"[ -n \"yar53\" ]" -> (BUILTIN_TEST (n (STRING (DOUBLE_QUOTED_STRING yar53))))
-"test 5 -eq 6" -> (BUILTIN_TEST (eq 5 6))
+"test 5 -eq 6" -> (BUILTIN_TEST (eq (STRING 5) (STRING 6)))
"[[ \"asdf\" != \"boo\" && -a filename ]]" -> (KEYWORD_TEST (&& (!= (STRING (DOUBLE_QUOTED_STRING asdf)) (STRING (DOUBLE_QUOTED_STRING boo))) (a (STRING filename))))
"[[ true ]]" -> (KEYWORD_TEST (STRING true))
"[[ true && (false || three) ]]" -> (KEYWORD_TEST (&& (STRING true) (|| (STRING false) (STRING three))))
diff --git a/bashast/gunit/expansions.gunit b/bashast/gunit/expansions.gunit
index 17436e8..c4af25b 100644
--- a/bashast/gunit/expansions.gunit
+++ b/bashast/gunit/expansions.gunit
@@ -22,7 +22,8 @@ clist:
"echo a{b,c,d}" -> (LIST (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c) (STRING d)))))
"((5+5))" -> (LIST (COMPOUND_ARITH (+ 5 5)))
"(( 4 + asdf ))" -> (LIST (COMPOUND_ARITH (+ 4 (VAR_REF asdf))))
-"[[ while=while ]] && echo true" -> (LIST (&& (COMPOUND_COND (KEYWORD_TEST (= (STRING while) (STRING while)))) (COMMAND (STRING echo) (STRING true))))
+"[[ while=while ]] && echo true" -> (LIST (&& (COMPOUND_COND (KEYWORD_TEST (STRING while = while))) (COMMAND (STRING echo) (STRING true))))
+"[[ while = while ]] && echo true" -> (LIST (&& (COMPOUND_COND (KEYWORD_TEST (= (STRING while) (STRING while)))) (COMMAND (STRING echo) (STRING true))))
"for each in `ls |grep output`; do
echo $each
done" -> (LIST (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))))))
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-05-11 7:19 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-05-11 7:19 UTC (permalink / raw
To: gentoo-commits
commit: cf469e4715154d0a5edd8052a7f1bb01209f3daa
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Sun May 8 10:46:26 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon May 9 12:45:47 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=cf469e47
Parser: Use virtual token for '*' and '?'
* and ? have different meanings in pattern matching. Now virtual
tokens are used to get a clear AST. The order of extended and
basic pattern matching is switched to make the '*' and '?'
correctly parsed.
---
bashast/bashast.g | 10 +++++++---
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/compound.gunit | 10 +++++-----
bashast/gunit/param_main.gunit | 2 +-
bashast/libbashWalker.g | 4 ++--
5 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 51fe9a9..429474e 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -70,6 +70,8 @@ tokens{
MATCH_AT_LEAST_ONE;
MATCH_PATTERN;
MATCH_ANY_EXCEPT;
+ MATCH_ALL;
+ MATCH_ONE;
CHARACTER_CLASS;
EQUIVALENCE_CLASS;
COLLATING_SYMBOL;
@@ -416,8 +418,8 @@ fname_part
| res_word_str;
//non-quoted string part rule, allows expansions
nqstr_part
- : bracket_pattern_match
- | extended_pattern_match
+ : extended_pattern_match
+ | bracket_pattern_match
| var_ref
| command_sub
| arithmetic_expansion
@@ -452,7 +454,9 @@ bracket_pattern_match
: LSQUARE RSQUARE (BANG|CARET) pattern_match* RSQUARE -> ^(MATCH_ANY_EXCEPT RSQUARE pattern_match*)
| LSQUARE RSQUARE pattern_match* RSQUARE -> ^(MATCH_PATTERN RSQUARE pattern_match*)
| LSQUARE (BANG|CARET) pattern_match+ RSQUARE -> ^(MATCH_ANY_EXCEPT pattern_match+)
- | LSQUARE pattern_match+ RSQUARE -> ^(MATCH_PATTERN pattern_match+);
+ | LSQUARE pattern_match+ RSQUARE -> ^(MATCH_PATTERN pattern_match+)
+ | TIMES -> MATCH_ALL
+ | QMARK -> MATCH_ONE;
//allowable patterns with bracket pattern matching
pattern_match
: pattern_class_match
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index b9b6c62..920a23a 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c
)))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))
) (CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1))) (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay))))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (IF_STATEMENT (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong)))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS
_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAN
D (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF failedtests)) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF (VAR_REF z)) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c
)))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING
each)))) (CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1))) (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay))))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (IF_STATEMENT (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong)))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc)
(PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar)))))
(COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/compound.gunit b/bashast/gunit/compound.gunit
index 398bb3d..a7ce999 100644
--- a/bashast/gunit/compound.gunit
+++ b/bashast/gunit/compound.gunit
@@ -65,7 +65,7 @@ echo three
;;
*) echo woo
;;
-esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
+esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
"case `echo asdf` in
gz)
@@ -75,10 +75,10 @@ esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_
echo three
;;
*) echo woo
-esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
+esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
"case `echo asdf` in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo esac" FAIL
-"case `echo asdf` in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo ;; esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) (STRING asdf) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
+"case `echo asdf` in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo ;; esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) (STRING asdf) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
for_expr:
"for each in `ls |grep log`; do
@@ -147,7 +147,7 @@ case_expr:
echo \"Usage: $0 start|stop\" >&2
exit 3
;;
-esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING *) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING Usage : (VAR_REF 0) start | stop)) (REDIR >& 2)) (COMMAND (STRING exit) (STRING 3)))))
+esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING Usage : (VAR_REF 0) start | stop)) (REDIR >& 2)) (COMMAND (STRING exit) (STRING 3)))))
"case $asdf in
a)
@@ -168,4 +168,4 @@ stop)
echo \"Usage: $0 start|stop\" >&2
exit 3
;;
-esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING stop)) (CASE_PATTERN (STRING *) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING Usage : (VAR_REF 0) start | stop)) (REDIR >& 2)) (COMMAND (STRING exit) (STRING 3)))))
+esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING stop)) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING Usage : (VAR_REF 0) start | stop)) (REDIR >& 2)) (COMMAND (STRING exit) (STRING 3)))))
diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit
index 61cc140..b273d3d 100644
--- a/bashast/gunit/param_main.gunit
+++ b/bashast/gunit/param_main.gunit
@@ -39,7 +39,7 @@ var_ref:
"${foo##bar}" -> (VAR_REF (REPLACE_AT_START foo (STRING bar)))
"${foo%bar}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING bar)))
"${foo%%bar}" -> (VAR_REF (REPLACE_AT_END foo (STRING bar)))
-"${foo%; *}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING ; *)))
+"${foo%; *}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING ; MATCH_ALL)))
"${foo%/}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING /)))
"${this/is/pattern}"->(VAR_REF (REPLACE_FIRST this (STRING is) (STRING pattern)))
//Test positional/special parameters
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index f39e603..fb3add0 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -550,8 +550,8 @@ case_clause[const std::string& target] returns[bool matched]
case_pattern returns[std::string libbash_value]
:libbash_string=command_substitution { $libbash_value = libbash_string; }
- |string_expr { $libbash_value = $string_expr.libbash_value; }
- |TIMES { $libbash_value = "*"; };
+ |(^(STRING MATCH_ALL)) => ^(STRING MATCH_ALL) { $libbash_value = "*"; }
+ |string_expr { $libbash_value = $string_expr.libbash_value; };
command_substitution returns[std::string libbash_value]
@declarations {
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-06-03 14:48 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-06-03 14:48 UTC (permalink / raw
To: gentoo-commits
commit: 3c205fa899c6ebce42588a3129f6b30851e62858
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 3 08:32:04 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Jun 3 12:53:48 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=3c205fa8
Parser: improve redirection handling
The alternative "DIGIT MINUS?" is duplicated so it's removed. The
rule is refactored to generate a better AST.
---
bashast/bashast.g | 9 ++++-----
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/compound.gunit | 4 ++--
bashast/gunit/list.gunit | 4 ++--
bashast/gunit/redir.gunit | 5 +++--
bashast/libbashWalker.g | 9 ++++-----
6 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index de8158a..edbadf5 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -151,12 +151,11 @@ redirect: BLANK!* here_string_op^ BLANK!* fname
| BLANK* redir_op BLANK* redir_dest -> ^(REDIR redir_op redir_dest)
| BLANK!* process_substitution;
redir_dest
- : DIGIT MINUS?
- | fname //path to a file
- | file_desc_as_file; //handles file descriptors0
+ : file_desc_as_file //handles file descriptors
+ | fname; //path to a file
file_desc_as_file
- : AMP DIGIT -> FILE_DESCRIPTOR[$DIGIT]
- | AMP DIGIT MINUS -> FILE_DESCRIPTOR_MOVE[$DIGIT];
+ : DIGIT -> ^(FILE_DESCRIPTOR DIGIT)
+ | DIGIT MINUS -> ^(FILE_DESCRIPTOR_MOVE DIGIT);
heredoc : (fname EOL!)*;
here_string_op
: HERE_STRING_OP;
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 1a53b15..cfc15ba 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))) (COMMAND (S
TRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (CFOR (FOR
_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1))) (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay))))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (IF_STATEMENT (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong)))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTIO
N < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (V
AR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& 1) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))) (COMMAND (S
TRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (CFOR (FOR
_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1))) (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay))))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (IF_STATEMENT (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong)))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTIO
N < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (V
AR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& (FILE_DESCRIPTOR 1)) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/compound.gunit b/bashast/gunit/compound.gunit
index 6651be2..d5cc211 100644
--- a/bashast/gunit/compound.gunit
+++ b/bashast/gunit/compound.gunit
@@ -148,7 +148,7 @@ case_expr:
echo \"Usage: $0 start|stop\" >&2
exit 3
;;
-esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING Usage : (VAR_REF 0) start | stop)) (REDIR >& 2)) (COMMAND (STRING exit) (STRING 3)))))
+esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING Usage : (VAR_REF 0) start | stop)) (REDIR >& (FILE_DESCRIPTOR 2))) (COMMAND (STRING exit) (STRING 3)))))
"case $asdf in
a)
@@ -169,4 +169,4 @@ stop)
echo \"Usage: $0 start|stop\" >&2
exit 3
;;
-esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING stop)) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING Usage : (VAR_REF 0) start | stop)) (REDIR >& 2)) (COMMAND (STRING exit) (STRING 3)))))
+esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING stop)) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING Usage : (VAR_REF 0) start | stop)) (REDIR >& (FILE_DESCRIPTOR 2))) (COMMAND (STRING exit) (STRING 3)))))
diff --git a/bashast/gunit/list.gunit b/bashast/gunit/list.gunit
index dcb2754..4beb325 100644
--- a/bashast/gunit/list.gunit
+++ b/bashast/gunit/list.gunit
@@ -41,5 +41,5 @@ echo \"a b\"" -> (LIST (VARIABLE_DEFINITIONS (= a (STRING asdf))) (VARIABLE_DEFI
"FOO='bar' ;" -> (LIST (VARIABLE_DEFINITIONS (= FOO (STRING (SINGLE_QUOTED_STRING bar)))))
"true;
true" -> (LIST (COMMAND (STRING true)) (COMMAND (STRING true)))
-"(echo hi > /dev/null) >> 1" -> (LIST (SUBSHELL (LIST (COMMAND (STRING echo) (STRING hi) (REDIR > (STRING / dev / null)))) (REDIR >> 1)))
-"{ echo hi > /dev/null; } >> 1" -> (LIST (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi) (REDIR > (STRING / dev / null)))) (REDIR >> 1)))
+"(echo hi > /dev/null) >> 1" -> (LIST (SUBSHELL (LIST (COMMAND (STRING echo) (STRING hi) (REDIR > (STRING / dev / null)))) (REDIR >> (FILE_DESCRIPTOR 1))))
+"{ echo hi > /dev/null; } >> 1" -> (LIST (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi) (REDIR > (STRING / dev / null)))) (REDIR >> (FILE_DESCRIPTOR 1))))
diff --git a/bashast/gunit/redir.gunit b/bashast/gunit/redir.gunit
index d1506d6..5b0a0c7 100644
--- a/bashast/gunit/redir.gunit
+++ b/bashast/gunit/redir.gunit
@@ -21,12 +21,13 @@ gunit bashast;
redirect:
">output_file" -> (REDIR > (STRING output_file))
"1>output.file" -> (REDIR 1 > (STRING output . file))
-"2>&1" -> (REDIR 2 >& 1)
+"2>&1" -> (REDIR 2 >& (FILE_DESCRIPTOR 1))
+"2>&1-" -> (REDIR 2 >& (FILE_DESCRIPTOR_MOVE 1))
">> /this/is/append" -> (REDIR >> (STRING / this / is / append))
"&> allout" -> (REDIR &> (STRING allout))
"< this.is.1input" -> (REDIR < (STRING this . is . 1 input))
"3< \"input from file\"" -> (REDIR 3 < (STRING (DOUBLE_QUOTED_STRING input from file)))
-"2<&0" -> (REDIR 2 <& 0)
+"2<&0" -> (REDIR 2 <& (FILE_DESCRIPTOR 0))
"<< asdf
asdf
" -> (<< (STRING asdf) (STRING asdf))
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index af19dcd..58de4b7 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -506,15 +506,14 @@ redirect
};
redirect_destination
- :DIGIT MINUS?
- |string_expr //path to a file
- |FILE_DESCRIPTOR
- |FILE_DESCRIPTOR_MOVE;
+ :string_expr //path to a file
+ |FILE_DESCRIPTOR DIGIT
+ |FILE_DESCRIPTOR_MOVE DIGIT;
redirect_operator
:LESS_THAN
|GREATER_THAN
- |DIGIT redirect_operator;
+ |FILE_DESCRIPTOR DIGIT redirect_operator;
argument[std::vector<std::string>& args]
: string_expr {
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-06-09 13:41 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-06-09 13:41 UTC (permalink / raw
To: gentoo-commits
commit: d0451516ab58979cf819b5c99f606566085113c0
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Thu Jun 9 13:10:17 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Jun 9 13:10:17 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=d0451516
Parser: fix {GNUmakefile,{M,m}akefile}
The first alternative can match everything through fname so the second
was just confusing ANTLR.
---
bashast/bashast.g | 1 -
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/brace.gunit | 3 ++-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 4b132f5..af5cfcf 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -181,7 +181,6 @@ range : DIGIT DOTDOT^ DIGIT
| LETTER DOTDOT^ LETTER;
brace_expansion_part
: (((~COMMA) => fname_part)+ -> ^(STRING fname_part+))+
- | brace_expansion
| -> EMPTY_BRACE_EXPANSION_ATOM;
commasep: brace_expansion_part(COMMA! brace_expansion_part)+;
command_sub
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index cfc15ba..79ae39b 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))) (COMMAND (S
TRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (CFOR (FOR
_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1))) (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay))))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (IF_STATEMENT (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong)))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTIO
N < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (V
AR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& (FILE_DESCRIPTOR 1)) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))) (COMMAND (S
TRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING (BRACE_EXP (STRING a) (STRING b))) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (
CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1))) (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay))))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (IF_STATEMENT (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong)))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SU
BSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (
STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& (FILE_DESCRIPTOR 1)) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/brace.gunit b/bashast/gunit/brace.gunit
index 584face..1930560 100644
--- a/bashast/gunit/brace.gunit
+++ b/bashast/gunit/brace.gunit
@@ -23,8 +23,9 @@ brace_expansion:
"{$a/$b,b}"-> (BRACE_EXP (STRING (VAR_REF a) / (VAR_REF b)) (STRING b))
"{a,b,c}" -> (BRACE_EXP (STRING a) (STRING b) (STRING c))
"{a..d}" -> (BRACE_EXP (.. a d))
-"{{a,b},c,d}" -> (BRACE_EXP (BRACE_EXP (STRING a) (STRING b)) (STRING c) (STRING d))
+"{{a,b},c,d}" -> (BRACE_EXP (STRING (BRACE_EXP (STRING a) (STRING b))) (STRING c) (STRING d))
"{.txt,,}" -> (BRACE_EXP (STRING . txt) EMPTY_BRACE_EXPANSION_ATOM EMPTY_BRACE_EXPANSION_ATOM)
+"{GNUmakefile,{M,m}akefile}" -> (BRACE_EXP (STRING GNUmakefile) (STRING (BRACE_EXP (STRING M) (STRING m)) akefile))
fname:
"a{b,c}" -> (STRING a (BRACE_EXP (STRING b) (STRING c)))
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-06-11 8:24 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-06-11 8:24 UTC (permalink / raw
To: gentoo-commits
commit: 51ebf80929749cd1962e3e5b845c4346d41daafb
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Thu Jun 9 17:11:18 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Jun 10 14:44:07 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=51ebf809
Parser: fix handling ))
Having the special token confused statements like array=($(echo))
where the two parenthesis are part of different constructs.
---
bashast/bashast.g | 9 ++++-----
bashast/features_script/features.sh.tokens | 10 +++++-----
bashast/gunit/array.gunit | 1 +
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index a8d44d5..269fcfd 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -200,7 +200,7 @@ compound_command
| cond_comparison;
//Expressions allowed inside a compound command
for_expr: FOR BLANK+ name (wspace IN (BLANK+ fname)+)? semiel DO wspace* clist semiel DONE -> ^(FOR name (fname+)? clist)
- | FOR BLANK* LLPAREN EOL? (BLANK* init=arithmetic BLANK*|BLANK+)? (SEMIC (BLANK? fcond=arithmetic BLANK*|BLANK+)? SEMIC|DOUBLE_SEMIC) (BLANK* mod=arithmetic)? wspace* RRPAREN semiel DO wspace clist semiel DONE
+ | FOR BLANK* LLPAREN EOL? (BLANK* init=arithmetic BLANK*|BLANK+)? (SEMIC (BLANK? fcond=arithmetic BLANK*|BLANK+)? SEMIC|DOUBLE_SEMIC) (BLANK* mod=arithmetic)? wspace* RPAREN RPAREN semiel DO wspace clist semiel DONE
-> ^(CFOR ^(FOR_INIT $init)? ^(FOR_COND $fcond)? clist ^(FOR_MOD $mod)?)
;
sel_expr: SELECT BLANK+ name (wspace IN BLANK+ word)? semiel DO wspace* clist semiel DONE -> ^(SELECT name (word)? clist)
@@ -235,7 +235,7 @@ current_shell
: LBRACE wspace clist semiel wspace* RBRACE redirect? -> ^(CURRENT_SHELL clist redirect?);
//comparison using arithmetic
arith_comparison
- : LLPAREN wspace? arithmetic wspace? RRPAREN -> ^(COMPOUND_ARITH arithmetic);
+ : LLPAREN wspace? arithmetic wspace? RPAREN RPAREN -> ^(COMPOUND_ARITH arithmetic);
cond_comparison
: cond_expr -> ^(COMPOUND_COND cond_expr);
//Variables
@@ -554,13 +554,13 @@ arithmetics
: arithmetic (COMMA! BLANK!* arithmetic)*;
//explicit arithmetic in places like array indexes
explicit_arithmetic
- : (DOLLAR LLPAREN BLANK*)? arithmetics RRPAREN? -> arithmetics
+ : (DOLLAR LLPAREN BLANK*)? arithmetics (RPAREN RPAREN)? -> arithmetics
| (DOLLAR LSQUARE BLANK*)? arithmetics RSQUARE? -> arithmetics;
//Arithmetic expansion
//the square bracket from is deprecated
//http://permalink.gmane.org/gmane.comp.shells.bash.bugs/14479
arithmetic_expansion
- : DOLLAR LLPAREN BLANK* arithmetics BLANK* RRPAREN -> ^(ARITHMETIC_EXPRESSION arithmetics)
+ : DOLLAR LLPAREN BLANK* arithmetics BLANK* RPAREN RPAREN -> ^(ARITHMETIC_EXPRESSION arithmetics)
| DOLLAR LSQUARE BLANK* arithmetics BLANK* RSQUARE -> ^(ARITHMETIC_EXPRESSION arithmetics);
process_substitution
@@ -613,7 +613,6 @@ TIME : 'time';
RPAREN : ')';
LPAREN : '(';
LLPAREN : '((';
-RRPAREN : '))';
LSQUARE : '[';
RSQUARE : ']';
TICK : '`';
diff --git a/bashast/features_script/features.sh.tokens b/bashast/features_script/features.sh.tokens
index 7823bd6..797f232 100644
--- a/bashast/features_script/features.sh.tokens
+++ b/bashast/features_script/features.sh.tokens
@@ -29,10 +29,10 @@
29 RBRACE EOL
30
31 NAME LPAREN RPAREN BLANK LBRACE EOL
-32 BLANK LLPAREN BLANK DIGIT TIMES DIGIT BLANK RRPAREN EOL
-33 BLANK LLPAREN BLANK DIGIT EXP DIGIT BLANK RRPAREN EOL
-34 BLANK LLPAREN BLANK DOLLAR NAME PLUS DIGIT SLASH DIGIT BLANK RRPAREN EOL
-35 BLANK LLPAREN BLANK DOLLAR LETTER PLUS MINUS DIGIT BLANK RRPAREN EOL
+32 BLANK LLPAREN BLANK DIGIT TIMES DIGIT BLANK RPAREN RPAREN EOL
+33 BLANK LLPAREN BLANK DIGIT EXP DIGIT BLANK RPAREN RPAREN EOL
+34 BLANK LLPAREN BLANK DOLLAR NAME PLUS DIGIT SLASH DIGIT BLANK RPAREN RPAREN EOL
+35 BLANK LLPAREN BLANK DOLLAR LETTER PLUS MINUS DIGIT BLANK RPAREN RPAREN EOL
36 RBRACE EOL
37
38 FUNCTION BLANK NAME LPAREN RPAREN BLANK LPAREN EOL
@@ -67,7 +67,7 @@
67 BLANK NAME BLANK NAME EOL
68 DONE EOL
69
-70 FOR BLANK LLPAREN DIGIT PLUS DIGIT SEMIC DIGIT PLUS DIGIT SEMIC DIGIT PLUS DIGIT RRPAREN SEMIC BLANK DO BLANK NAME BLANK NAME SEMIC BLANK DONE EOL
+70 FOR BLANK LLPAREN DIGIT PLUS DIGIT SEMIC DIGIT PLUS DIGIT SEMIC DIGIT PLUS DIGIT RPAREN RPAREN SEMIC BLANK DO BLANK NAME BLANK NAME SEMIC BLANK DONE EOL
71
72 SELECT BLANK NAME BLANK IN BLANK TICK NAME BLANK PIPE NAME BLANK NAME TICK SEMIC BLANK DO EOL
73 BLANK NAME BLANK NAME BLANK DIGIT GREATER_THAN BLANK SLASH NAME SLASH NAME EOL
diff --git a/bashast/gunit/array.gunit b/bashast/gunit/array.gunit
index eb11be8..b9cb121 100644
--- a/bashast/gunit/array.gunit
+++ b/bashast/gunit/array.gunit
@@ -22,6 +22,7 @@ var_def:
"asdf=(a b c d)"->(= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))
"asdf=(`echo 6` b c d)"-> (= asdf (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))
"asdf=(${P} b c d)"->(= asdf (ARRAY (STRING (VAR_REF P)) (STRING b) (STRING c) (STRING d)))
+"asdf=($(echo a))" -> (= asdf (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING a)))))))
"asdf=(
--disable-dependency-tracking
${VAR}
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-06-14 8:28 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-06-14 8:28 UTC (permalink / raw
To: gentoo-commits
commit: a8b675bbda92360a13eb5047a75db738aa4bc73b
Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Jun 11 11:27:42 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Jun 11 11:27:42 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=a8b675bb
Parser: remove redundant word rule
---
bashast/bashast.g | 12 ++----------
bashast/features_script/features.sh.ast | 2 +-
bashast/gunit/compound.gunit | 18 +++++++++---------
3 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 17e8fbb..2db45de 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -203,7 +203,7 @@ for_expr: FOR BLANK+ name (wspace IN (BLANK+ fname)+)? semiel DO wspace* clist s
| FOR BLANK* LLPAREN EOL? (BLANK* init=arithmetic BLANK*|BLANK+)? (SEMIC (BLANK? fcond=arithmetic BLANK*|BLANK+)? SEMIC|DOUBLE_SEMIC) (BLANK* mod=arithmetic)? wspace* RPAREN RPAREN semiel DO wspace clist semiel DONE
-> ^(CFOR ^(FOR_INIT $init)? ^(FOR_COND $fcond)? clist ^(FOR_MOD $mod)?)
;
-sel_expr: SELECT BLANK+ name (wspace IN BLANK+ word)? semiel DO wspace* clist semiel DONE -> ^(SELECT name (word)? clist)
+sel_expr: SELECT BLANK+ name (wspace IN BLANK+ fname)? semiel DO wspace* clist semiel DONE -> ^(SELECT name fname? clist)
;
if_expr : IF wspace+ ag=clist semiel THEN wspace+ iflist=clist semiel EOL* (elif_expr)* (ELSE wspace+ else_list=clist semiel EOL*)? FI
-> ^(IF_STATEMENT ^(IF $ag $iflist) (elif_expr)* ^(ELSE $else_list)?)
@@ -218,7 +218,7 @@ until_expr
;
// double semicolon is optional for the last alternative
case_expr
- : CASE BLANK+ word wspace IN wspace case_body? ESAC -> ^(CASE word case_body?);
+ : CASE BLANK+ fname wspace IN wspace case_body? ESAC -> ^(CASE fname case_body?);
case_body
: case_stmt (wspace* DOUBLE_SEMIC case_stmt)* wspace* DOUBLE_SEMIC? wspace* -> case_stmt*;
case_stmt
@@ -389,14 +389,6 @@ cond_part: brace_expansion
wspace : BLANK+|EOL+;
semiel : BLANK* (SEMIC EOL?|EOL) BLANK*;
-//definition of word. this is just going to grow...
-word : (brace_expansion) => brace_expansion
- | (command_sub) => command_sub
- | (var_ref) => var_ref
- | (num) => num
- | (arithmetic_expansion) => arithmetic_expansion
- | fname;
-
num
options{k=1;backtrack=false;}
: DIGIT|NUMBER;
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 79ae39b..2f042d4 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))) (COMMAND (S
TRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING (BRACE_EXP (STRING a) (STRING b))) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each)))) (
CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1))) (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay))))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (IF_STATEMENT (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong)))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SU
BSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (
STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& (FILE_DESCRIPTOR 1)) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests)))))) (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMPOUND_ARITH (* 5 4)) (COMPOUND_ARITH (** 5 4)) (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4))) (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))) (function (STRING arrays) (SUBSHELL (LIST (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d)))) (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3))) (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))) (COMMAND (S
TRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING (BRACE_EXP (STRING a) (STRING b))) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (case (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf))))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo))))) (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING e
ach)))) (CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1))) (select each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null))))) (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay))))) (until (LIST (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile)))) (while (LIST (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) (IF_STATEMENT (if (LIST (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong)))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRI
NG wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (VARIABLE_DEFINITIONS (= asdf (STRING parameters))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING b
ar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& (FILE_DESCRIPTOR 1)) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/gunit/compound.gunit b/bashast/gunit/compound.gunit
index d5cc211..a6d056a 100644
--- a/bashast/gunit/compound.gunit
+++ b/bashast/gunit/compound.gunit
@@ -54,7 +54,7 @@ subshell:
case_expr:
"case a in esac" -> (case (STRING a))
"case `echo asdf` in
-esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))))
+esac" -> (case (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf))))))
"case `echo asdf` in
gz)
@@ -65,9 +65,9 @@ echo three
;;
*) echo woo
;;
-esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
+esac" -> (case (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf))))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
-"case `echo asdf` in
+"case asdf in
gz)
echo yay
;;
@@ -75,10 +75,10 @@ esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_
echo three
;;
*) echo woo
-esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
+esac" -> (case (STRING asdf) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
"case `echo asdf` in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo esac" FAIL
-"case `echo asdf` in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo ;; esac" -> (case (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf)))) (CASE_PATTERN (STRING gz) (STRING asdf) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
+"case asdf in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo ;; esac" -> (case (STRING asdf) (CASE_PATTERN (STRING gz) (STRING asdf) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))
for_expr:
"for each in `ls |grep log`; do
@@ -98,8 +98,8 @@ done" -> (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND
sel_expr:
"select each in `ls |grep log`; do
echo \"file found\"
- done" -> (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
-"select each in `ls |grep log`; do echo \"file found\"; done" -> (select each (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
+ done" -> (select each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
+"select each in `ls |grep log`; do echo \"file found\"; done" -> (select each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
"select each in `ls |grep log`; do echo file done" FAIL
if_expr:
@@ -154,13 +154,13 @@ esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRIN
a)
echo \"yay\"
;;
-esac" -> (case (VAR_REF asdf) (CASE_PATTERN (STRING a) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING yay))))))
+esac" -> (case (STRING (VAR_REF asdf)) (CASE_PATTERN (STRING a) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING yay))))))
"case asdf in
asdf)
echo \"yay\"
;;
esac" -> (case (STRING asdf) (CASE_PATTERN (STRING asdf) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING yay))))))
-"case 1 in 1) echo yay ;; esac" -> (case 1 (CASE_PATTERN (STRING 1) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))))
+"case 1 in 1) echo yay ;; esac" -> (case (STRING 1) (CASE_PATTERN (STRING 1) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))))
"case /usr/bin in 1) echo yay ;; esac" -> (case (STRING / usr / bin) (CASE_PATTERN (STRING 1) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))))
"case \"$1\" in
stop)
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-06-25 10:30 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-06-25 10:30 UTC (permalink / raw
To: gentoo-commits
commit: b0c44f96d41a6127fe36ef200904d2c0f5ab65f0
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 20 10:57:45 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Jun 22 11:56:02 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=b0c44f96
Parser: rename arith_comparison
The arith_comparison rule is renamed to arithmetic_expression as it's
the name from bash manual.
---
bashast/bashast.g | 9 ++++-----
bashast/features_script/features.sh.ast | 2 +-
bashast/features_script/features.sh.walker.tokens | 2 +-
bashast/gunit/compound.gunit | 10 +++++-----
bashast/gunit/expansions.gunit | 4 ++--
5 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 571ed54..ffb699f 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -36,7 +36,6 @@ tokens{
CASE_COMMAND;
SUBSHELL;
CURRENT_SHELL;
- COMPOUND_ARITH;
COMPOUND_COND;
CFOR;
FOR_INIT;
@@ -200,7 +199,7 @@ compound_command
| case_expr
| subshell
| current_shell
- | arith_comparison
+ | arithmetic_expression
| cond_comparison;
//Expressions allowed inside a compound command
for_expr: FOR BLANK+ name (wspace IN (BLANK+ fname)+)? semiel DO wspace* clist semiel DONE -> ^(FOR name (fname+)? clist)
@@ -233,9 +232,9 @@ subshell: LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAREN -> ^(
//A grouping of commands executed in the current shell
current_shell
: LBRACE wspace clist semiel wspace* RBRACE -> ^(CURRENT_SHELL clist);
-//comparison using arithmetic
-arith_comparison
- : LLPAREN wspace? arithmetic wspace? RPAREN RPAREN -> ^(COMPOUND_ARITH arithmetic);
+//Bash arithmetic expression (( expression ))
+arithmetic_expression
+ : LLPAREN wspace? arithmetic wspace? RPAREN RPAREN -> ^(ARITHMETIC_EXPRESSION arithmetic);
cond_comparison
: cond_expr -> ^(COMPOUND_COND cond_expr);
//Variables
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 7217880..4191c85 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (COMMAND (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests))))))) (COMMAND (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMMAND (COMPOUND_ARITH (* 5 4))) (COMMAND (COMPOUND_ARITH (** 5 4))) (COMMAND (COMPOUND_ARITH (+ (VAR_REF failedtests) (/ 5 4)))) (COMMAND (COMPOUND_ARITH (+ (VAR_REF z) (MINUS_SIGN 3)))))))) (COMMAND (function (STRING arrays) (SUBSHELL (LIST (COMMAND (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (COMMAND (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d))))) (COMMAND (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING
3)))) (COMMAND (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING (BRACE_EXP (STRING a) (STRING b))) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (COMMAND (case (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf))))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))) (COMMAND (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls
)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each))))) (COMMAND (CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1)))) (COMMAND (select each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null)))))) (COMMAND (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))))) (COMMAND (until (LIST (COMMAND (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile)))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile))))) (COMMAND (while (LIST (COMMAND (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))) (COMMAND (IF_STATEMENT (if (LIST (COMMAND (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (ST
RING 6)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (COMMAND (VARIABLE_DEFINITIONS (= asdf (STRING parameters)))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (
STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (COMMAND (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& (FILE_DESCRIPTOR 1)) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<
< (STRING word))))
+(LIST (COMMAND (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests))))))) (COMMAND (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMMAND (ARITHMETIC_EXPRESSION (* 5 4))) (COMMAND (ARITHMETIC_EXPRESSION (** 5 4))) (COMMAND (ARITHMETIC_EXPRESSION (+ (VAR_REF failedtests) (/ 5 4)))) (COMMAND (ARITHMETIC_EXPRESSION (+ (VAR_REF z) (MINUS_SIGN 3)))))))) (COMMAND (function (STRING arrays) (SUBSHELL (LIST (COMMAND (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (COMMAND (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d))))) (COMMAND (VARIABLE_DEFINITIONS (=
(arr (VAR_REF foo)) (STRING 3)))) (COMMAND (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING (BRACE_EXP (STRING a) (STRING b))) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (COMMAND (case (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf))))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))) (COMMAND (for each (STRING (COMMAND_SUB
(LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each))))) (COMMAND (CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1)))) (COMMAND (select each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null)))))) (COMMAND (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))))) (COMMAND (until (LIST (COMMAND (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile)))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile))))) (COMMAND (while (LIST (COMMAND (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))) (COMMAND (IF_STATEMENT (if (LIST (COMMAND (COMPOUND_COND (BUI
LTIN_TEST (eq (STRING 5) (STRING 6)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (COMMAND (VARIABLE_DEFINITIONS (= asdf (STRING parameters)))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_R
EF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (COMMAND (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& (FILE_DESCRIPTOR 1)) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (S
TRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/features_script/features.sh.walker.tokens b/bashast/features_script/features.sh.walker.tokens
index 673b88b..255caa7 100644
--- a/bashast/features_script/features.sh.walker.tokens
+++ b/bashast/features_script/features.sh.walker.tokens
@@ -1,2 +1,2 @@
-LIST DOWN COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP CURRENT_SHELL DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME COLON BLANK VAR_REF DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN SINGLE_QUOTED_STRING DOWN DOLLAR NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME UP UP UP UP UP UP UP COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP CURRENT_SHELL DOWN LIST DOWN COMMAND DOWN COMPOUND_ARITH DOWN TIMES DOWN DIGIT DIGIT UP UP UP COMMAND DOWN COMPOUND_ARITH DOWN EXP DOWN DIGIT DIGIT UP UP UP COMMAND DOWN COMPOUND_ARITH DOWN PLUS DOWN VAR_REF DOWN NAME UP SLASH DOWN DIGIT DIGIT UP UP UP UP COMMAND DOWN COMPOUND_ARITH DOWN PLUS DOWN VAR_REF DOWN LETTER UP MINUS_SIGN DOWN DIGIT UP UP UP UP UP UP UP UP COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP SUBSHELL DOWN LIST DOWN COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME A
RRAY DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME DOWN DIGIT UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DIGIT UP UP UP UP UP STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME DOWN VAR_REF DOWN NAME UP UP STRING DOWN DIGIT UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP EQUALS DOWN DIGIT STRING DOWN LETTER UP UP UP UP UP UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN DOTDOT DOWN LETTER LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING
DOWN BRACE_EXP DOWN STRING DOWN BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN LETTER BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP REDIR DOWN OP STRING DOWN NAME UP UP UP UP COMMAND DOWN CASE DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP CASE_PATTERN DOWN STRING DOWN NAME UP CASE_COMMAND LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP CASE_PATTERN DOWN STRING DOWN NAME UP CASE_COMMAND LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP CASE_PATTERN DOWN STRING DOWN MATCH_ALL UP CASE_COMMAND LIST DOWN COMMAND DOWN STRI
NG DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP COMMAND DOWN FOR DOWN NAME STRING DOWN COMMAND_SUB DOWN LIST DOWN PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN CFOR DOWN FOR_INIT DOWN PLUS DOWN DIGIT DIGIT UP UP FOR_COND DOWN PLUS DOWN DIGIT DIGIT UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP FOR_MOD DOWN PLUS DOWN DIGIT DIGIT UP UP UP UP COMMAND DOWN SELECT DOWN NAME STRING DOWN COMMAND_SUB DOWN LIST DOWN PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN DIGIT UP REDIR DOWN GREATER_THAN STRING DOWN SLASH NAME SLASH NAME UP UP UP UP UP UP COMMAND DOWN IF_STATEMENT DOWN IF DOWN LIST D
OWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP COMMAND DOWN UNTIL DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN KEYWORD_TEST DOWN LETTER DOWN STRING DOWN NAME SLASH NAME DOT NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME SLASH NAME DOT NAME UP UP UP UP UP COMMAND DOWN WHILE DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN BUILTIN_TEST DOWN LETTER DOWN STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME BLANK NAME UP UP UP UP UP UP COMMAND DOWN IF_STATEMENT DOWN IF DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN BUILTIN_TEST DOWN NAME DOWN STRING DOWN DIGIT UP STRING DOWN DIGIT UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME SQUOTE LETTER BLANK NAME UP UP UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRIN
G DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP PROCESS_SUBSTITUTION DOWN LESS_THAN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN SLASH NAME SLASH NAME SLASH NAME SLASH NAME DOT NAME UP UP UP UP UP LOGICOR DOWN LOGICAND DOWN LOGICAND DOWN LOGICAND DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN DOT SLASH NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN SLASH NAME SLASH NAME UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN MINUS NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME STRING DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN USE_DEFAULT_WHEN_UNSET_OR_NULL DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DO
WN VAR_REF DOWN OFFSET DOWN NAME DIGIT UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN BANG DOWN NAME TIMES UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN BANG DOWN NAME AT UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN POUND DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_FIRST DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_START DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_START DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_END DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_END DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN DIGIT UP UP STRING DOWN VAR_REF DOWN AT UP UP STRING DOWN VAR_REF DOWN TIMES UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN QMARK UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_
ALL DOWN NAME STRING DOWN DOT UP STRING DOWN UNDERSCORE UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_START DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_END DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME STRING DOWN VAR_REF DOWN REPLACE_FIRST DOWN NAME STRING DOWN NAME MINUS UP UP UP UP UP UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN DIGIT UP REDIR DOWN OP FILE_DESCRIPTOR DOWN DIGIT UP UP REDIR DOWN GREATER_THAN STRING DOWN SLASH NAME SLASH NAME UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP REDIR DOWN OP STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP HERE_STRING_OP DOWN STRING DOWN NAME UP UP UP UP
+LIST DOWN COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP CURRENT_SHELL DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME COLON BLANK VAR_REF DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN SINGLE_QUOTED_STRING DOWN DOLLAR NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME UP UP UP UP UP UP UP COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP CURRENT_SHELL DOWN LIST DOWN COMMAND DOWN ARITHMETIC_EXPRESSION DOWN TIMES DOWN DIGIT DIGIT UP UP UP COMMAND DOWN ARITHMETIC_EXPRESSION DOWN EXP DOWN DIGIT DIGIT UP UP UP COMMAND DOWN ARITHMETIC_EXPRESSION DOWN PLUS DOWN VAR_REF DOWN NAME UP SLASH DOWN DIGIT DIGIT UP UP UP UP COMMAND DOWN ARITHMETIC_EXPRESSION DOWN PLUS DOWN VAR_REF DOWN LETTER UP MINUS_SIGN DOWN DIGIT UP UP UP UP UP UP UP UP COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP SUBSHELL DOWN LIST DOWN COMMAND DOWN VARIABLE_DEFINIT
IONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME DOWN DIGIT UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DIGIT UP UP UP UP UP STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME DOWN VAR_REF DOWN NAME UP UP STRING DOWN DIGIT UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP EQUALS DOWN DIGIT STRING DOWN LETTER UP UP UP UP UP UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN DOTDOT DOWN LETTER LETTER UP UP UP UP COMMAND DOW
N STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN STRING DOWN BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN LETTER BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP REDIR DOWN OP STRING DOWN NAME UP UP UP UP COMMAND DOWN CASE DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP CASE_PATTERN DOWN STRING DOWN NAME UP CASE_COMMAND LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP CASE_PATTERN DOWN STRING DOWN NAME UP CASE_COMMAND LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP CASE_PATTERN DOWN STRING DOWN MATCH_ALL UP CASE_COMMAND
LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP COMMAND DOWN FOR DOWN NAME STRING DOWN COMMAND_SUB DOWN LIST DOWN PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN CFOR DOWN FOR_INIT DOWN PLUS DOWN DIGIT DIGIT UP UP FOR_COND DOWN PLUS DOWN DIGIT DIGIT UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP FOR_MOD DOWN PLUS DOWN DIGIT DIGIT UP UP UP UP COMMAND DOWN SELECT DOWN NAME STRING DOWN COMMAND_SUB DOWN LIST DOWN PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN DIGIT UP REDIR DOWN GREATER_THAN STRING DOWN SLASH NAME SLASH NAME UP UP UP UP UP UP COMMAND DOWN IF_S
TATEMENT DOWN IF DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP COMMAND DOWN UNTIL DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN KEYWORD_TEST DOWN LETTER DOWN STRING DOWN NAME SLASH NAME DOT NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME SLASH NAME DOT NAME UP UP UP UP UP COMMAND DOWN WHILE DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN BUILTIN_TEST DOWN LETTER DOWN STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME BLANK NAME UP UP UP UP UP UP COMMAND DOWN IF_STATEMENT DOWN IF DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN BUILTIN_TEST DOWN NAME DOWN STRING DOWN DIGIT UP STRING DOWN DIGIT UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME SQUOTE LETTER BLANK NAME UP UP UP UP UP UP UP COMMAND DOWN STRING DOWN NAME
UP STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP PROCESS_SUBSTITUTION DOWN LESS_THAN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN SLASH NAME SLASH NAME SLASH NAME SLASH NAME DOT NAME UP UP UP UP UP LOGICOR DOWN LOGICAND DOWN LOGICAND DOWN LOGICAND DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN DOT SLASH NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN SLASH NAME SLASH NAME UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN MINUS NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME STRING DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN USE_DEFAULT_WHEN_UNSET_OR_NULL DOWN NAME STRING DOWN NAME UP UP UP
UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN OFFSET DOWN NAME DIGIT UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN BANG DOWN NAME TIMES UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN BANG DOWN NAME AT UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN POUND DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_FIRST DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_START DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_START DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_END DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_END DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN DIGIT UP UP STRING DOWN VAR_REF DOWN AT UP UP STRING DOWN VAR_REF DOWN TIMES UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN QMARK UP UP UP COMMAND DOWN STRIN
G DOWN VAR_REF DOWN REPLACE_ALL DOWN NAME STRING DOWN DOT UP STRING DOWN UNDERSCORE UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_START DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_END DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME STRING DOWN VAR_REF DOWN REPLACE_FIRST DOWN NAME STRING DOWN NAME MINUS UP UP UP UP UP UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN DIGIT UP REDIR DOWN OP FILE_DESCRIPTOR DOWN DIGIT UP UP REDIR DOWN GREATER_THAN STRING DOWN SLASH NAME SLASH NAME UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP REDIR DOWN OP STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP HERE_STRING_OP DOWN STRING DOWN NAME UP UP UP UP
diff --git a/bashast/gunit/compound.gunit b/bashast/gunit/compound.gunit
index 3ea38a6..26d51e2 100644
--- a/bashast/gunit/compound.gunit
+++ b/bashast/gunit/compound.gunit
@@ -28,9 +28,9 @@ cond_comparison:
"[[ asdf > qwert ]]" -> (COMPOUND_COND (KEYWORD_TEST (> (STRING asdf) (STRING qwert))))
"[ asdf \> qwert ]" -> (COMPOUND_COND (BUILTIN_TEST (\> (STRING asdf) (STRING qwert))))
-arith_comparison:
-"((5+3))" -> (COMPOUND_ARITH (+ 5 3))
-"(( 5+3 ))" -> (COMPOUND_ARITH (+ 5 3))
+arithmetic_expression:
+"((5+3))" -> (ARITHMETIC_EXPRESSION (+ 5 3))
+"(( 5+3 ))" -> (ARITHMETIC_EXPRESSION (+ 5 3))
current_shell:
"{ time cat; }" -> (CURRENT_SHELL (LIST (COMMAND (STRING cat) time)))
@@ -128,7 +128,7 @@ while_expr:
echo \"file found\"
done" -> (while (LIST (COMMAND (STRING echo) (STRING true))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
"while echo true; do echo \"file found\"; done" -> (while (LIST (COMMAND (STRING echo) (STRING true))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
-"while(( 1>0 )); do echo ok; done" -> (while (LIST (COMMAND (COMPOUND_ARITH (> 1 0)))) (LIST (COMMAND (STRING echo) (STRING ok))))
+"while(( 1>0 )); do echo ok; done" -> (while (LIST (COMMAND (ARITHMETIC_EXPRESSION (> 1 0)))) (LIST (COMMAND (STRING echo) (STRING ok))))
"while echo true`; do echo file done" FAIL
"while [[ -n \"$ver_str\" ]] ; do
echo true
@@ -172,7 +172,7 @@ esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING
command:
"[[ asdf > qwert ]] > /dev/null" -> (COMMAND (COMPOUND_COND (KEYWORD_TEST (> (STRING asdf) (STRING qwert)))) (REDIR > (STRING / dev / null)))
-"(( 5+3 )) > /dev/null" -> (COMMAND (COMPOUND_ARITH (+ 5 3)) (REDIR > (STRING / dev / null)))
+"(( 5+3 )) > /dev/null" -> (COMMAND (ARITHMETIC_EXPRESSION (+ 5 3)) (REDIR > (STRING / dev / null)))
"{ time cat; } > /dev/null" -> (COMMAND (CURRENT_SHELL (LIST (COMMAND (STRING cat) time))) (REDIR > (STRING / dev / null)))
"(time cat) > /dev/null" -> (COMMAND (SUBSHELL (LIST (COMMAND (STRING cat) time))) (REDIR > (STRING / dev / null)))
"case a in esac >/dev/null" -> (COMMAND (case (STRING a)) (REDIR > (STRING / dev / null)))
diff --git a/bashast/gunit/expansions.gunit b/bashast/gunit/expansions.gunit
index 3cc5632..20c54f1 100644
--- a/bashast/gunit/expansions.gunit
+++ b/bashast/gunit/expansions.gunit
@@ -20,8 +20,8 @@ gunit bashast;
clist:
"echo a{b,c,d}" -> (LIST (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c) (STRING d)))))
-"((5+5))" -> (LIST (COMMAND (COMPOUND_ARITH (+ 5 5))))
-"(( 4 + asdf ))" -> (LIST (COMMAND (COMPOUND_ARITH (+ 4 (VAR_REF asdf)))))
+"((5+5))" -> (LIST (COMMAND (ARITHMETIC_EXPRESSION (+ 5 5))))
+"(( 4 + asdf ))" -> (LIST (COMMAND (ARITHMETIC_EXPRESSION (+ 4 (VAR_REF asdf)))))
"[[ while=while ]] && echo true" -> (LIST (&& (COMMAND (COMPOUND_COND (KEYWORD_TEST (STRING while = while)))) (COMMAND (STRING echo) (STRING true))))
"[[ while = while ]] && echo true" -> (LIST (&& (COMMAND (COMPOUND_COND (KEYWORD_TEST (= (STRING while) (STRING while))))) (COMMAND (STRING echo) (STRING true))))
"for each in `ls |grep output`; do
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-08-04 13:53 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-08-04 13:53 UTC (permalink / raw
To: gentoo-commits
commit: b6a7f5f3676b27710c8e47ed1a37c90915e75e1c
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 22 08:10:59 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Aug 2 07:46:29 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=b6a7f5f3
Parser: fix array size expansion
The token for "##" is removed in order to support ${##}.
---
bashast/bashast.g | 13 ++++++-------
bashast/features_script/features.sh.tokens | 2 +-
bashast/gunit/param_main.gunit | 8 ++++++++
bashast/gunit/simp_command.gunit | 2 +-
4 files changed, 16 insertions(+), 9 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 : '/';
diff --git a/bashast/features_script/features.sh.tokens b/bashast/features_script/features.sh.tokens
index 25c95d3..af1b075 100644
--- a/bashast/features_script/features.sh.tokens
+++ b/bashast/features_script/features.sh.tokens
@@ -105,7 +105,7 @@
105 DOLLAR LBRACE POUND NAME RBRACE EOL
106 DOLLAR LBRACE NAME SLASH NAME SLASH NAME RBRACE EOL
107 DOLLAR LBRACE NAME POUND NAME RBRACE EOL
-108 DOLLAR LBRACE NAME POUNDPOUND NAME RBRACE EOL
+108 DOLLAR LBRACE NAME POUND POUND NAME RBRACE EOL
109 DOLLAR LBRACE NAME PCT NAME RBRACE EOL
110 DOLLAR LBRACE NAME PCT NAME RBRACE EOL
111 DOLLAR DIGIT BLANK DOLLAR AT BLANK DOLLAR TIMES EOL
diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit
index c83ccc2..27fc273 100644
--- a/bashast/gunit/param_main.gunit
+++ b/bashast/gunit/param_main.gunit
@@ -57,6 +57,7 @@ variable_reference:
"$*" -> (VAR_REF *)
"${@}" -> (VAR_REF @)
"${#}" -> (VAR_REF #)
+"$#" -> (VAR_REF #)
"${!foo}" -> (VAR_REF (VAR_REF foo))
"${!#}" -> (VAR_REF (VAR_REF #))
"${3}" -> (VAR_REF 3)
@@ -75,6 +76,13 @@ variable_reference:
"${PN/wrong#/#correct}" -> (VAR_REF (REPLACE_FIRST PN (STRING wrong #) (STRING # correct)))
"${a/b/\}c}" -> (VAR_REF (REPLACE_FIRST a (STRING b) (STRING \ } c)))
"${a/b/a\}c}" -> (VAR_REF (REPLACE_FIRST a (STRING b) (STRING a \ } c)))
+"${#var}" -> (VAR_REF (# var))
+"${#var[@]}" -> (VAR_REF (# (var ARRAY_SIZE)))
+"${#var[*]}" -> (VAR_REF (# (var ARRAY_SIZE)))
+"${#@}" -> (VAR_REF (# @))
+"${#*}" -> (VAR_REF (# *))
+"${##}" -> (VAR_REF (# #))
+"${#$}" -> (VAR_REF (# $))
variable_definition_atom:
"MY_PN=${PN/asterisk-}" -> (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))))
diff --git a/bashast/gunit/simp_command.gunit b/bashast/gunit/simp_command.gunit
index 965b351..8e9a443 100644
--- a/bashast/gunit/simp_command.gunit
+++ b/bashast/gunit/simp_command.gunit
@@ -29,7 +29,7 @@ command_atom:
"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 \"ab#af ###\" #abc" -> (STRING echo) (STRING (DOUBLE_QUOTED_STRING ab # af ## #))
+"echo \"ab#af ###\" #abc" -> (STRING echo) (STRING (DOUBLE_QUOTED_STRING ab # af # # #))
command:
"asdf=5 cat out.log > result" -> (COMMAND (STRING cat) (STRING out . log) (= asdf (STRING 5)) (REDIR > (STRING result)))
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/
@ 2011-08-04 13:53 Petteri Räty
0 siblings, 0 replies; 21+ messages in thread
From: Petteri Räty @ 2011-08-04 13:53 UTC (permalink / raw
To: gentoo-commits
commit: 10a48abd4df32b33d70b4b73857af96219564301
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 22 10:38:07 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Aug 2 07:52:16 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=10a48abd
Parser: allow command name that starts with 'test'
---
bashast/bashast.g | 4 ++--
bashast/features_script/features.sh.tokens | 2 +-
bashast/gunit/simp_command.gunit | 1 +
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))
^ permalink raw reply related [flat|nested] 21+ messages in thread
end of thread, other threads:[~2011-08-04 13:55 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-11 6:50 [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/, bashast/features_script/ Petteri Räty
-- strict thread matches above, loose matches on Subject: below --
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-06-25 10:30 Petteri Räty
2011-06-14 8:28 Petteri Räty
2011-06-11 8:24 Petteri Räty
2011-06-09 13:41 Petteri Räty
2011-06-03 14:48 Petteri Räty
2011-05-11 7:19 Petteri Räty
2011-04-27 15:11 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-17 10:58 Petteri Räty
2011-04-17 10:58 Petteri Räty
2011-04-17 10:58 Petteri Räty
2011-04-17 10:58 Petteri Räty
2011-04-17 10:58 Petteri Räty
2011-04-17 10:58 Petteri Räty
2011-04-17 10:58 Petteri Räty
2011-04-12 7:19 Petteri Räty
2011-04-12 7:19 Petteri Räty
2011-04-11 6:50 Petteri Räty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox