* [gentoo-commits] proj/libbash:master commit in: /, bashast/
@ 2011-08-04 13:53 Petteri Räty
0 siblings, 0 replies; only message in thread
From: Petteri Räty @ 2011-08-04 13:53 UTC (permalink / raw
To: gentoo-commits
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;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-08-04 13:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-04 13:53 [gentoo-commits] proj/libbash:master commit in: /, bashast/ Petteri Räty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox