From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/
Date: Wed, 20 Jul 2011 13:08:55 +0000 (UTC) [thread overview]
Message-ID: <b697380ce491408052730c892c898fe669b1b8e7.betelgeuse@gentoo> (raw)
commit: b697380ce491408052730c892c898fe669b1b8e7
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 6 09:11:00 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Jul 20 08:34:15 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=b697380c
Parser: remove blank for the start of pipeline rule
Most rules that call pipeline will handle the leading blanks themselves.
---
bashast/bashast.g | 33 +++++++++++++++++----------------
bashast/gunit/expansions.gunit | 2 +-
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 1b4548e..32e79d5 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -164,11 +164,11 @@ tokens{
}
#endif
-start : (flcomment)? EOL* clist BLANK* (SEMIC|AMP|EOL)? EOF -> clist;
+start : (flcomment)? EOL* BLANK* command_list BLANK* (SEMIC|AMP|EOL)? EOF -> command_list;
//Because the comment token doesn't handle the first comment in a file if it's on the first line, have a parser rule for it
flcomment
: POUND ~(EOL)* EOL;
-clist
+command_list
: list_level_2 -> ^(LIST list_level_2);
list_level_1
: pipeline (BLANK!*(LOGICAND^|LOGICOR^)(BLANK!|EOL!)* pipeline)*;
@@ -180,7 +180,7 @@ command_separator
| AMP^
| EOL!;
pipeline
- : BLANK!* time? ((BANG) => (BANG BLANK!+))? command^ (BLANK!* PIPE^ BLANK!* command)*;
+ : time? ((BANG) => (BANG BLANK!+))? command^ (BLANK!* PIPE^ BLANK!* command)*;
time : TIME^ BLANK!+ ((time_posix) => time_posix)?;
time_posix
: MINUS! LETTER BLANK!+;
@@ -313,22 +313,23 @@ compound_command
| 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)
- | 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)?)
+for_expr: FOR BLANK+ name (wspace IN (BLANK+ fname)+)? semiel DO wspace* command_list semiel DONE
+ -> ^(FOR name (fname+)? command_list)
+ | 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* command_list semiel DONE
+ -> ^(CFOR ^(FOR_INIT $init)? ^(FOR_COND $fcond)? command_list ^(FOR_MOD $mod)?)
;
-sel_expr: SELECT BLANK+ name (wspace IN BLANK+ fname)? semiel DO wspace* clist semiel DONE -> ^(SELECT name fname? clist)
+sel_expr: SELECT BLANK+ name (wspace IN BLANK+ fname)? semiel DO wspace* command_list semiel DONE -> ^(SELECT name fname? command_list)
;
-if_expr : IF wspace+ ag=clist semiel THEN wspace+ iflist=clist semiel wspace* (elif_expr)* (ELSE wspace+ else_list=clist semiel EOL*)? FI
+if_expr : IF wspace+ ag=command_list semiel THEN wspace+ iflist=command_list semiel wspace* (elif_expr)* (ELSE wspace+ else_list=command_list semiel EOL*)? FI
-> ^(IF_STATEMENT ^(IF $ag $iflist) (elif_expr)* ^(ELSE $else_list)?)
;
elif_expr
- : ELIF BLANK+ ag=clist semiel THEN wspace+ iflist=clist semiel -> ^(IF["if"] $ag $iflist);
+ : ELIF BLANK+ ag=command_list semiel THEN wspace+ iflist=command_list semiel -> ^(IF["if"] $ag $iflist);
while_expr
- : WHILE wspace? istrue=clist semiel DO wspace dothis=clist semiel DONE -> ^(WHILE $istrue $dothis)
+ : WHILE wspace* istrue=command_list semiel DO wspace* dothis=command_list semiel DONE -> ^(WHILE $istrue $dothis)
;
until_expr
- : UNTIL wspace? istrue=clist semiel DO wspace dothis=clist semiel DONE -> ^(UNTIL $istrue $dothis)
+ : UNTIL wspace* istrue=command_list semiel DO wspace* dothis=command_list semiel DONE -> ^(UNTIL $istrue $dothis)
;
// double semicolon is optional for the last alternative
case_expr
@@ -336,13 +337,13 @@ case_expr
case_body
: case_stmt (wspace* DOUBLE_SEMIC case_stmt)* wspace* DOUBLE_SEMIC? wspace* -> case_stmt*;
case_stmt
- : wspace* (LPAREN BLANK*)? fname (BLANK* PIPE BLANK? fname)* BLANK* RPAREN (wspace* clist)?
- -> ^(CASE_PATTERN fname+ (CASE_COMMAND clist)?);
+ : wspace* (LPAREN BLANK*)? fname (BLANK* PIPE BLANK? fname)* BLANK* RPAREN (wspace* command_list)?
+ -> ^(CASE_PATTERN fname+ (CASE_COMMAND command_list)?);
//A grouping of commands executed in a subshell
-subshell: LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAREN -> ^(SUBSHELL clist );
+subshell: LPAREN wspace* command_list (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAREN -> ^(SUBSHELL command_list);
//A grouping of commands executed in the current shell
current_shell
- : LBRACE wspace clist semiel wspace* RBRACE -> ^(CURRENT_SHELL clist);
+ : LBRACE wspace* command_list semiel wspace* RBRACE -> ^(CURRENT_SHELL command_list);
//Bash arithmetic expression (( expression ))
arithmetic_expression
: LLPAREN wspace? arithmetic wspace? RPAREN RPAREN -> ^(ARITHMETIC_EXPRESSION arithmetic);
@@ -658,7 +659,7 @@ arithmetic_expansion
| DOLLAR LSQUARE BLANK* arithmetics BLANK* RSQUARE -> ^(ARITHMETIC_EXPRESSION arithmetics);
process_substitution
- : (dir=LESS_THAN|dir=GREATER_THAN)LPAREN clist BLANK* RPAREN -> ^(PROCESS_SUBSTITUTION $dir clist);
+ : (dir=LESS_THAN|dir=GREATER_THAN)LPAREN BLANK* command_list BLANK* RPAREN -> ^(PROCESS_SUBSTITUTION $dir command_list);
esc_char: ESC (DIGIT DIGIT? DIGIT?|LETTER ALPHANUM ALPHANUM?|.);
//****************
diff --git a/bashast/gunit/expansions.gunit b/bashast/gunit/expansions.gunit
index b10931d..2414e0a 100644
--- a/bashast/gunit/expansions.gunit
+++ b/bashast/gunit/expansions.gunit
@@ -18,7 +18,7 @@
*/
gunit java_libbash;
-clist:
+command_list:
"echo a{b,c,d}" -> (LIST (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c) (STRING d)))))
"((5+5))" -> (LIST (COMMAND (ARITHMETIC_EXPRESSION (+ 5 5))))
"(( 4 + asdf ))" -> (LIST (COMMAND (ARITHMETIC_EXPRESSION (+ 4 (VAR_REF asdf)))))
next reply other threads:[~2011-07-20 13:09 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-20 13:08 Petteri Räty [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-08-19 14:35 [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/ Petteri Räty
2012-06-03 9:08 Petteri Räty
2012-06-03 9:08 Petteri Räty
2012-06-03 9:08 Petteri Räty
2012-06-03 9:08 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-07-08 14:12 Petteri Räty
2011-06-21 13:26 Petteri Räty
2011-06-21 13:20 Petteri Räty
2011-06-21 13:20 Petteri Räty
2011-06-19 19:15 Petteri Räty
2011-06-15 21:18 Petteri Räty
2011-06-14 8:28 Petteri Räty
2011-06-14 8:28 Petteri Räty
2011-06-11 8:24 Petteri Räty
2011-06-11 8:24 Petteri Räty
2011-06-09 13:41 Petteri Räty
2011-06-09 13:41 Petteri Räty
2011-06-09 8:15 Petteri Räty
2011-06-01 12:03 Petteri Räty
2011-06-01 12:03 Petteri Räty
2011-06-01 12:03 Petteri Räty
2011-06-01 12:03 Petteri Räty
2011-06-01 12:03 Petteri Räty
2011-05-23 14:34 Petteri Räty
2011-05-22 21:00 Petteri Räty
2011-05-11 7:19 Petteri Räty
2011-05-11 7:19 Petteri Räty
2011-05-11 7:19 Petteri Räty
2011-05-07 12:25 Petteri Räty
2011-04-27 15:11 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 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-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-17 10:58 Petteri Räty
2011-04-17 10:58 Petteri Räty
2011-04-14 4:50 Petteri Räty
2011-04-14 4:50 Petteri Räty
2011-04-14 4:50 Petteri Räty
2011-04-12 7:19 Petteri Räty
2011-04-12 7:19 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
2011-04-11 6:50 Petteri Räty
2011-04-11 6:50 Petteri Räty
2011-04-11 6:50 Petteri Räty
2011-04-11 5:21 Petteri Räty
2011-04-11 5:21 Petteri Räty
2011-04-11 5:21 Petteri Räty
2011-04-11 5:21 Petteri Räty
2011-04-09 6:27 Petteri Räty
2011-04-09 6:27 Petteri Räty
2011-04-09 6:27 Petteri Räty
2011-04-09 6:27 Petteri Räty
2011-04-08 14:26 Petteri Räty
2011-04-07 16:45 Petteri Räty
2011-04-07 7:48 Petteri Räty
2011-04-06 7:43 Petteri Räty
2011-03-30 12:48 Petteri Räty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b697380ce491408052730c892c898fe669b1b8e7.betelgeuse@gentoo \
--to=betelgeuse@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox