public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/, bashast/gunit/, bashast/features_script/
Date: Thu,  4 Aug 2011 13:53:45 +0000 (UTC)	[thread overview]
Message-ID: <dadb0328ad3a9fea42ee98da34c254a60b130866.betelgeuse@gentoo> (raw)

commit:     dadb0328ad3a9fea42ee98da34c254a60b130866
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 28 12:43:35 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Aug  2 07:52:19 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=dadb0328

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
 		);
 
 command_atom
-	:	(FOR|SELECT|IF|WHILE|UNTIL|CASE|LPAREN|LBRACE|LLPAREN|LSQUARE|TEST_EXPR) => compound_command
+	:	{LA(1) == FOR|| LA(1) == SELECT|| LA(1) == IF|| LA(1) == WHILE|| LA(1) == UNTIL||
+		 LA(1) == CASE|| LA(1) == LPAREN|| LA(1) == LBRACE|| LA(1) == LLPAREN|| LA(1) == LSQUARE||
+#ifdef OUTPUT_C
+		(LA(1) == NAME && LA(2) == BLANK && "test" == get_string(LT(1)))}? => compound_command
+#else
+		(LA(1) == NAME && LA(2) == BLANK && "test".equals(get_string(LT(1))))}? => 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)) => 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 builtin_condition)
-	|	TEST_EXPR wspace? builtin_condition-> ^(BUILTIN_TEST builtin_condition);
+#ifdef OUTPUT_C
+	|	{LA(1) == NAME && LA(2) == BLANK && get_string(LT(1)) == "test"}? => NAME wspace? builtin_condition-> ^(BUILTIN_TEST builtin_condition);
+#else
+	|	{LA(1) == NAME && LA(2) == BLANK && "test".equals(get_string(LT(1)))}? => NAME wspace? builtin_condition-> ^(BUILTIN_TEST builtin_condition);
+#endif
 
 keyword_condition
 	:	((BANG) => keyword_negation_primary|keyword_condition_primary) (BLANK!? (LOGICOR^|LOGICAND^) BLANK!? keyword_condition)?;
@@ -720,7 +730,7 @@ string_part
 
 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	:	'?';
 
-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 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	
-88	IF BLANK TEST_EXPR DIGIT BLANK MINUS NAME BLANK DIGIT SEMIC BLANK THEN EOL
+88	IF BLANK NAME BLANK 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/cond_main.gunit b/bashast/gunit/cond_main.gunit
index 7b0aee5..fbf785e 100644
--- a/bashast/gunit/cond_main.gunit
+++ b/bashast/gunit/cond_main.gunit
@@ -36,3 +36,4 @@ condition_expr:
 "[[ \"${element}\" =~ (^[^[:space:]]+\ .) ]]" -> (KEYWORD_TEST (MATCH_REGULAR_EXPRESSION (STRING (DOUBLE_QUOTED_STRING (VAR_REF element))) (STRING ( ^ [ ^ [ : space : ] ] + \   . ))))
 "[[ a<b ]]" -> (KEYWORD_TEST (< (STRING a) (STRING b)))
 "[[ a>b ]]" -> (KEYWORD_TEST (> (STRING a) (STRING b)))
+"[[ ${VIRTUALX_REQUIRED} == always || ${VIRTUALX_REQUIRED} == test ]]" -> (KEYWORD_TEST (|| (MATCH_PATTERN (STRING (VAR_REF VIRTUALX_REQUIRED)) (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=" \t\n"
 
 if true; then
     function_in_compound_statement() {
@@ -93,3 +94,5 @@ function shift_test() {
 }
 
 shift_test 1 2
+test-flag-CC() { echo "CC" "$1"; }
+test-flag-CC abc



             reply	other threads:[~2011-08-04 13:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-04 13:53 Petteri Räty [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-06-03  9:08 [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/, bashast/gunit/, bashast/features_script/ Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-04-27 15:11 Petteri Räty
2011-04-27 15:11 Petteri Räty
2011-04-27 15:11 Petteri Räty
2011-04-14  4:50 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=dadb0328ad3a9fea42ee98da34c254a60b130866.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