From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QjWWQ-0003o1-DW for garchives@archives.gentoo.org; Wed, 20 Jul 2011 13:09:06 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 75B2621C0CA; Wed, 20 Jul 2011 13:08:57 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3A52721C0CA for ; Wed, 20 Jul 2011 13:08:57 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id ABE662AC092 for ; Wed, 20 Jul 2011 13:08:56 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 7D5F880042 for ; Wed, 20 Jul 2011 13:08:55 +0000 (UTC) From: "Petteri Räty" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" Message-ID: Subject: [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/bashast.g bashast/gunit/expansions.gunit X-VCS-Directories: bashast/ bashast/gunit/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: b697380ce491408052730c892c898fe669b1b8e7 Date: Wed, 20 Jul 2011 13:08:55 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: cfe0f06266e8e8923a8ff634a2e9ee94 commit: b697380ce491408052730c892c898fe669b1b8e7 Author: Mu Qiao gentoo org> AuthorDate: Wed Jul 6 09:11:00 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Wed Jul 20 08:34:15 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3Db697380c 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 =20 -start : (flcomment)? EOL* clist BLANK* (SEMIC|AMP|EOL)? EOF -> clist; +start : (flcomment)? EOL* BLANK* command_list BLANK* (SEMIC|AMP|EOL)? EO= F -> command_list; //Because the comment token doesn't handle the first comment in a file i= f 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) =3D> (BANG BLANK!+))? command^ (BLANK!* PIPE^ B= LANK!* command)*; + : time? ((BANG) =3D> (BANG BLANK!+))? command^ (BLANK!* PIPE^ BLANK!* c= ommand)*; time : TIME^ BLANK!+ ((time_posix) =3D> 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=3Darithmetic BLANK*|BLANK+)? (SE= MIC (BLANK? fcond=3Darithmetic BLANK*|BLANK+)? SEMIC|DOUBLE_SEMIC) (BLANK= * mod=3Darithmetic)? 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=3Darithmetic BLANK*|BLANK+)? (SE= MIC (BLANK? fcond=3Darithmetic BLANK*|BLANK+)? SEMIC|DOUBLE_SEMIC) (BLANK= * mod=3Darithmetic)? wspace* RPAREN RPAREN semiel DO wspace* command_list= semiel DONE + -> ^(CFOR ^(FOR_INIT $init)? ^(FOR_COND $fcond)? command_list ^(FOR_MO= D $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=3Dclist semiel THEN wspace+ iflist=3Dclist semie= l wspace* (elif_expr)* (ELSE wspace+ else_list=3Dclist semiel EOL*)? FI +if_expr : IF wspace+ ag=3Dcommand_list semiel THEN wspace+ iflist=3Dcomm= and_list semiel wspace* (elif_expr)* (ELSE wspace+ else_list=3Dcommand_li= st semiel EOL*)? FI -> ^(IF_STATEMENT ^(IF $ag $iflist) (elif_expr)* ^(ELSE $else_list)?) ; elif_expr - : ELIF BLANK+ ag=3Dclist semiel THEN wspace+ iflist=3Dclist semiel -> ^= (IF["if"] $ag $iflist); + : ELIF BLANK+ ag=3Dcommand_list semiel THEN wspace+ iflist=3Dcommand_li= st semiel -> ^(IF["if"] $ag $iflist); while_expr - : WHILE wspace? istrue=3Dclist semiel DO wspace dothis=3Dclist semiel D= ONE -> ^(WHILE $istrue $dothis) + : WHILE wspace* istrue=3Dcommand_list semiel DO wspace* dothis=3Dcomman= d_list semiel DONE -> ^(WHILE $istrue $dothis) ; until_expr - : UNTIL wspace? istrue=3Dclist semiel DO wspace dothis=3Dclist semiel D= ONE -> ^(UNTIL $istrue $dothis) + : UNTIL wspace* istrue=3Dcommand_list semiel DO wspace* dothis=3Dcomman= d_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? wsp= ace* -> case_stmt*; case_stmt - : wspace* (LPAREN BLANK*)? fname (BLANK* PIPE BLANK? fname)* BLANK* RPA= REN (wspace* clist)? - -> ^(CASE_PATTERN fname+ (CASE_COMMAND clist)?); + : wspace* (LPAREN BLANK*)? fname (BLANK* PIPE BLANK? fname)* BLANK* RPA= REN (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* RPAR= EN -> ^(SUBSHELL clist ); +subshell: LPAREN wspace* command_list (BLANK* SEMIC)? (BLANK* EOL)* BLAN= K* 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_EXPR= ESSION arithmetic); @@ -658,7 +659,7 @@ arithmetic_expansion | DOLLAR LSQUARE BLANK* arithmetics BLANK* RSQUARE -> ^(ARITHMETIC_EXPR= ESSION arithmetics); =20 process_substitution - : (dir=3DLESS_THAN|dir=3DGREATER_THAN)LPAREN clist BLANK* RPAREN -> ^(P= ROCESS_SUBSTITUTION $dir clist); + : (dir=3DLESS_THAN|dir=3DGREATER_THAN)LPAREN BLANK* command_list BLANK*= RPAREN -> ^(PROCESS_SUBSTITUTION $dir command_list); esc_char: ESC (DIGIT DIGIT? DIGIT?|LETTER ALPHANUM ALPHANUM?|.); =20 //**************** diff --git a/bashast/gunit/expansions.gunit b/bashast/gunit/expansions.gu= nit index b10931d..2414e0a 100644 --- a/bashast/gunit/expansions.gunit +++ b/bashast/gunit/expansions.gunit @@ -18,7 +18,7 @@ */ gunit java_libbash; =20 -clist: +command_list: "echo a{b,c,d}" -> (LIST (COMMAND (STRING echo) (STRING a (BRACE_EXP (ST= RING b) (STRING c) (STRING d))))) "((5+5))" -> (LIST (COMMAND (ARITHMETIC_EXPRESSION (+ 5 5)))) "(( 4 + asdf ))" -> (LIST (COMMAND (ARITHMETIC_EXPRESSION (+ 4 (VAR_REF = asdf)))))