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 1QRk9E-00008m-N1 for garchives@archives.gentoo.org; Wed, 01 Jun 2011 12:03:41 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7E33D1C010; Wed, 1 Jun 2011 12:03:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 409C91C010 for ; Wed, 1 Jun 2011 12:03:12 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AD9EF1B401A for ; Wed, 1 Jun 2011 12:03:11 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 22BAF8050C for ; Wed, 1 Jun 2011 12:03:11 +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: <456744a2e9f0cae3231a02763ca852945c0e6c24.betelgeuse@gentoo> Subject: [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/bashast.g bashast/gunit/function.gunit bashast/gunit/list.gunit X-VCS-Directories: bashast/ bashast/gunit/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 456744a2e9f0cae3231a02763ca852945c0e6c24 Date: Wed, 1 Jun 2011 12:03:11 +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: 324aef10ff1edf4acfbfe38c989c00cd commit: 456744a2e9f0cae3231a02763ca852945c0e6c24 Author: Mu Qiao gentoo org> AuthorDate: Mon May 30 07:56:30 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Wed Jun 1 05:54:41 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3D456744a2 Parser: support redirection for command group Redirection in function definition is not necessary anymore as it will be matched by command group. --- bashast/bashast.g | 8 ++++---- bashast/gunit/function.gunit | 6 +++--- bashast/gunit/list.gunit | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bashast/bashast.g b/bashast/bashast.g index 2e892c2..26d362f 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -231,10 +231,10 @@ case_pattern | fname | TIMES; //A grouping of commands executed in a subshell -subshell: LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAR= EN -> ^(SUBSHELL clist); +subshell: LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAR= EN redirect* -> ^(SUBSHELL clist redirect*); //A grouping of commands executed in the current shell current_shell - : LBRACE wspace clist semiel wspace* RBRACE -> ^(CURRENT_SHELL clist); + : LBRACE wspace clist semiel wspace* RBRACE redirect* -> ^(CURRENT_SHEL= L clist redirect*); //comparison using arithmetic arith_comparison : LLPAREN wspace? arithmetic wspace? RRPAREN -> ^(COMPOUND_ARITH arithm= etic); @@ -560,8 +560,8 @@ arithmetic_expansion process_substitution : (dir=3DLESS_THAN|dir=3DGREATER_THAN)LPAREN clist BLANK* RPAREN -> ^(P= ROCESS_SUBSTITUTION $dir clist); //the biggie: functions -function: FUNCTION BLANK+ function_name ((BLANK* parens wspace*)|wspace)= compound_command redirect* -> ^(FUNCTION ^(STRING function_name) compoun= d_command redirect*) - | function_name BLANK* parens wspace* compound_command redirect* -> ^(F= UNCTION["function"] ^(STRING function_name) compound_command redirect*); +function: FUNCTION BLANK+ function_name ((BLANK* parens wspace*)|wspace)= compound_command -> ^(FUNCTION ^(STRING function_name) compound_command) + | function_name BLANK* parens wspace* compound_command -> ^(FUNCTION["f= unction"] ^(STRING function_name) compound_command); //http://article.gmane.org/gmane.comp.shells.bash.bugs/16424 //the rules from bash 3.2 general.c: //Make sure that WORD is a valid shell identifier, i.e. diff --git a/bashast/gunit/function.gunit b/bashast/gunit/function.gunit index 642318e..6ee6c68 100644 --- a/bashast/gunit/function.gunit +++ b/bashast/gunit/function.gunit @@ -32,11 +32,11 @@ function: "foo() { :; }" -> (function (STRING foo) (CURRENT_SHELL (LIST (COMMAND= (STRING :))))) "foo(){ :; }" -> (function (STRING foo) (CURRENT_SHELL (LIST (COMMAND (S= TRING :))))) =20 -"function quit { exit; } > /dev/null" -> (function (STRING quit) (CURREN= T_SHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null))) +"function quit { exit; } > /dev/null" -> (function (STRING quit) (CURREN= T_SHELL (LIST (COMMAND (STRING exit))) (REDIR > (STRING / dev / null)))) "function quit { # comment - 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) (CU= RRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi)))) (REDIR 2 > (STRIN= G / 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) (CU= RRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi))) (REDIR 2 > (STRING= / dev / null)))) "function help { echo 3; } 2> /dev/null > output" OK "xorg-2_reconf_source() { :; }" -> (function (STRING xorg - 2 _reconf_so= urce) (CURRENT_SHELL (LIST (COMMAND (STRING :))))) =20 diff --git a/bashast/gunit/list.gunit b/bashast/gunit/list.gunit index 76c46b2..dcb2754 100644 --- a/bashast/gunit/list.gunit +++ b/bashast/gunit/list.gunit @@ -41,3 +41,5 @@ echo \"a b\"" -> (LIST (VARIABLE_DEFINITIONS (=3D a (ST= RING asdf))) (VARIABLE_DEFI "FOO=3D'bar' ;" -> (LIST (VARIABLE_DEFINITIONS (=3D 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 e= cho) (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)))