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: /, bashast/
Date: Thu,  4 Aug 2011 13:53:38 +0000 (UTC)	[thread overview]
Message-ID: <2231ccbf755eaf9496e5f4cedfc6663491d2a982.betelgeuse@gentoo> (raw)

commit:     2231ccbf755eaf9496e5f4cedfc6663491d2a982
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 21 08:21:53 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 08:21:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=2231ccbf

Walker: reimplement the runtime for case statement

Now the test for compound statement is added back.

---
 Makefile.am             |    1 +
 bashast/libbashWalker.g |   31 ++++++++++++++-----------------
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 6a059a2..4bec991 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,6 +54,7 @@ BASH_TESTS = scripts/var_def.bash \
 			 scripts/var_expansion.bash \
 			 scripts/test_expr.bash \
 			 scripts/isolated_functions.bash \
+			 scripts/compound_command.bash \
 			 scripts/binary_arithmetic.bash
 
 EBUILD_LOG_COMPILER = $(srcdir)/test/ebuild_compiler.sh

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 4b0364e..c8962fd 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -357,7 +357,7 @@ composite_pattern[boost::xpressive::sregex& pattern_list, bool greedy]
 	sregex sub_pattern;
 }
 	:(^(BRANCH
-		(basic_pattern[sub_pattern, $greedy, do_sub_append]{
+		(basic_pattern[sub_pattern, $greedy, do_sub_append])+ {
 			if(do_append)
 			{
 				$pattern_list = sregex($pattern_list | sub_pattern);
@@ -368,7 +368,7 @@ composite_pattern[boost::xpressive::sregex& pattern_list, bool greedy]
 				do_append = true;
 			}
 			do_sub_append = false;
-		})+
+		}
 	))+;
 
 basic_pattern[boost::xpressive::sregex& pattern, bool greedy, bool& do_append]
@@ -987,27 +987,24 @@ case_expr
 
 case_clause[const std::string& target] returns[bool matched]
 @declarations {
-	std::vector<boost::xpressive::sregex> patterns;
+	boost::xpressive::sregex pattern;
 }
-	:^(CASE_PATTERN ( { patterns.push_back(boost::xpressive::sregex()); } bash_pattern[patterns.back(), true])+ {
-		$matched = false;
-
-		for(auto iter = patterns.begin(); iter != patterns.end(); ++iter)
+	:^(CASE_PATTERN composite_pattern[pattern, true] {
+		if(match(target, pattern))
 		{
-			if(match(target, *iter))
+			if(LA(1) == CASE_COMMAND)
 			{
-				if(LA(1) == CASE_COMMAND)
-				{
-					// omit CASE_COMMAND
-					SEEK(INDEX() + 1);
-					command_list(ctx);
-				}
-				$matched = true;
-				break;
+				// omit CASE_COMMAND
+				SEEK(INDEX() + 1);
+				command_list(ctx);
 			}
+			$matched = true;
 		}
-		if(!$matched)
+		else
+		{
+			$matched = false;
 			seek_to_next_tree(ctx);
+		}
 	})
 	|CASE_PATTERN;
 



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

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=2231ccbf755eaf9496e5f4cedfc6663491d2a982.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