From 694d48b56af21f1466aeb580faacab796cc5ea53 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 22 May 2012 15:47:02 -0300 Subject: [PATCH] b2/: make the match name after "break" and "continue" optional If the name is omitted, we jump back / out of the current block. --- b2/SUBST | 2 +- b2/lang.y | 4 ++++ b2/subst.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/b2/SUBST b/b2/SUBST index 164a636..2a7994f 100644 --- a/b2/SUBST +++ b/b2/SUBST @@ -8,7 +8,7 @@ BAR=x /* BAR= wouldn't be syntactically correct. We need a non-empty value */ FOO=(*)(?) { BAR=$BAR$2 FOO=$1 - continue FOO + continue } BAR=x(*) { $=$1 } /* remove the "x" */ diff --git a/b2/lang.y b/b2/lang.y index d5dae62..042da19 100644 --- a/b2/lang.y +++ b/b2/lang.y @@ -620,6 +620,10 @@ block: $$ = subst_end(); else if (!strcmp($1, "ignore")) $$ = subst_ignore(); + else if (!strcmp($1, "break")) + $$ = subst_break(NULL); + else if (!strcmp($1, "continue")) + $$ = subst_continue(NULL); else yyerrorf("unknown keyword \"%s\"", $1); } diff --git a/b2/subst.c b/b2/subst.c index 2f14df5..8003ca3 100644 --- a/b2/subst.c +++ b/b2/subst.c @@ -284,6 +284,8 @@ struct parent { static const struct subst *resolve_jump(const char *name, const struct parent *parent) { + if (!name) + return parent->sub; while (parent) { assert(parent->sub->type == st_match); if (name == parent->sub->u.match.src)