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 1QoyPS-0006VQ-0o for garchives@archives.gentoo.org; Thu, 04 Aug 2011 13:56:26 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 584C821C1FC; Thu, 4 Aug 2011 13:53:47 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 161C721C1FC for ; Thu, 4 Aug 2011 13:53:47 +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 88B7D2AC01C for ; Thu, 4 Aug 2011 13:53:46 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id E80B980048 for ; Thu, 4 Aug 2011 13:53:45 +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: scripts/, bashast/, bashast/gunit/, bashast/features_script/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/bashast.g bashast/features_script/features.sh.tokens bashast/gunit/cond_main.gunit scripts/function_def.bash X-VCS-Directories: scripts/ bashast/ bashast/gunit/ bashast/features_script/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: dadb0328ad3a9fea42ee98da34c254a60b130866 Date: Thu, 4 Aug 2011 13:53:45 +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: 4c8b462e708453640ac34a54b6947d29 commit: dadb0328ad3a9fea42ee98da34c254a60b130866 Author: Mu Qiao gentoo org> AuthorDate: Thu Jul 28 12:43:35 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Tue Aug 2 07:52:19 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3Ddadb0328 Parser: allow 'test' to be string literal --- bashast/bashast.g | 17 +++++++++++++---- bashast/features_script/features.sh.tokens | 2 +- bashast/gunit/cond_main.gunit | 1 + scripts/function_def.bash | 3 +++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/bashast/bashast.g b/bashast/bashast.g index 7dc9ad5..6d9ba7e 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -373,7 +373,13 @@ command ); =20 command_atom - : (FOR|SELECT|IF|WHILE|UNTIL|CASE|LPAREN|LBRACE|LLPAREN|LSQUARE|TEST_EX= PR) =3D> compound_command + : {LA(1) =3D=3D FOR|| LA(1) =3D=3D SELECT|| LA(1) =3D=3D IF|| LA(1) =3D= =3D WHILE|| LA(1) =3D=3D UNTIL|| + LA(1) =3D=3D CASE|| LA(1) =3D=3D LPAREN|| LA(1) =3D=3D LBRACE|| LA(1)= =3D=3D LLPAREN|| LA(1) =3D=3D LSQUARE|| +#ifdef OUTPUT_C + (LA(1) =3D=3D NAME && LA(2) =3D=3D BLANK && "test" =3D=3D get_string(L= T(1)))}? =3D> compound_command +#else + (LA(1) =3D=3D NAME && LA(2) =3D=3D BLANK && "test".equals(get_string(L= T(1))))}? =3D> compound_command +#endif | FUNCTION BLANK string_expr_no_reserved_word ((BLANK? parens wspace?)|= wspace) compound_command -> ^(FUNCTION string_expr_no_reserved_word compound_command) | (name (LSQUARE|EQUALS|PLUS EQUALS)) =3D> variable_definitions @@ -581,7 +587,11 @@ condition_comparison condition_expr : LSQUARE LSQUARE wspace keyword_condition wspace RSQUARE RSQUARE -> ^(= KEYWORD_TEST keyword_condition) | LSQUARE wspace builtin_condition wspace RSQUARE -> ^(BUILTIN_TEST bui= ltin_condition) - | TEST_EXPR wspace? builtin_condition-> ^(BUILTIN_TEST builtin_conditio= n); +#ifdef OUTPUT_C + | {LA(1) =3D=3D NAME && LA(2) =3D=3D BLANK && get_string(LT(1)) =3D=3D = "test"}? =3D> NAME wspace? builtin_condition-> ^(BUILTIN_TEST builtin_con= dition); +#else + | {LA(1) =3D=3D NAME && LA(2) =3D=3D BLANK && "test".equals(get_string(= LT(1)))}? =3D> NAME wspace? builtin_condition-> ^(BUILTIN_TEST builtin_co= ndition); +#endif =20 keyword_condition : ((BANG) =3D> keyword_negation_primary|keyword_condition_primary) (BLA= NK!? (LOGICOR^|LOGICAND^) BLANK!? keyword_condition)?; @@ -720,7 +730,7 @@ string_part =20 ns_string_part : num|name|escaped_character - |OTHER|EQUALS|PCT|PCTPCT|PLUS|MINUS|DOT|DOTDOT|COLON|TEST_EXPR + |OTHER|EQUALS|PCT|PCTPCT|PLUS|MINUS|DOT|DOTDOT|COLON |TILDE|LSQUARE|RSQUARE|CARET|POUND|COMMA|EXPORT|LOCAL|AT // Escaped characters |ESC_RPAREN|ESC_LPAREN|ESC_DOLLAR|ESC_GT|ESC_LT|ESC_TICK @@ -1084,7 +1094,6 @@ SLASH : '/'; COLON : ':'; QMARK : '?'; =20 -TEST_EXPR : 'test '; LOCAL : 'local'; EXPORT : 'export'; LOGICAND : '&&'; diff --git a/bashast/features_script/features.sh.tokens b/bashast/feature= s_script/features.sh.tokens index fc55123..f91800f 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=09 -88 IF BLANK TEST_EXPR DIGIT BLANK MINUS NAME BLANK DIGIT SEMIC BLANK THE= N EOL +88 IF BLANK NAME BLANK DIGIT BLANK MINUS NAME BLANK DIGIT SEMIC BLANK TH= EN EOL 89 BLANK NAME BLANK DQUOTE NAME SQUOTE LETTER BLANK NAME DQUOTE EOL 90 FI EOL 91=09 diff --git a/bashast/gunit/cond_main.gunit b/bashast/gunit/cond_main.guni= t index 7b0aee5..fbf785e 100644 --- a/bashast/gunit/cond_main.gunit +++ b/bashast/gunit/cond_main.gunit @@ -36,3 +36,4 @@ condition_expr: "[[ \"${element}\" =3D~ (^[^[:space:]]+\ .) ]]" -> (KEYWORD_TEST (MATCH_= REGULAR_EXPRESSION (STRING (DOUBLE_QUOTED_STRING (VAR_REF element))) (STR= ING ( ^ [ ^ [ : space : ] ] + \ . )))) "[[ a (KEYWORD_TEST (< (STRING a) (STRING b))) "[[ a>b ]]" -> (KEYWORD_TEST (> (STRING a) (STRING b))) +"[[ ${VIRTUALX_REQUIRED} =3D=3D always || ${VIRTUALX_REQUIRED} =3D=3D te= st ]]" -> (KEYWORD_TEST (|| (MATCH_PATTERN (STRING (VAR_REF VIRTUALX_REQU= IRED)) (STRING always)) (MATCH_PATTERN (STRING (VAR_REF VIRTUALX_REQUIRED= )) (STRING test)))) diff --git a/scripts/function_def.bash b/scripts/function_def.bash index 6f463a4..3918896 100644 --- a/scripts/function_def.bash +++ b/scripts/function_def.bash @@ -74,6 +74,7 @@ func_positional_args() { echo $* } func_positional_args 1 2 3 +IFS=3D" \t\n" =20 if true; then function_in_compound_statement() { @@ -93,3 +94,5 @@ function shift_test() { } =20 shift_test 1 2 +test-flag-CC() { echo "CC" "$1"; } +test-flag-CC abc