1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 09:16:15 +02:00

b2/: for consistency, make "break/continue $" equivalent to "break/continue"

Plus a bit of code simplification.
This commit is contained in:
Werner Almesberger 2012-05-22 15:57:55 -03:00
parent 694d48b56a
commit 4f142c1250
2 changed files with 18 additions and 12 deletions

View File

@ -37,7 +37,9 @@ with curly braces:
${foo}, ... ${foo}, ...
input variable (in pattern): input variable (in pattern):
$$ $$
the input variable ($) can also be used as LHS for matches and assignments
the input variable ($) can also be used as LHS for matches, assignments, and
as break/continue target.
Caveat: Caveat:

View File

@ -67,6 +67,15 @@ static const struct field *top_field(void)
} }
static struct subst *parse_jump(const char *keyword, const char *target)
{
if (!strcmp(keyword, "break"))
return subst_break(target);
if (!strcmp(keyword, "continue"))
return subst_continue(target);
yyerrorf("unknown keyword \"%s\"", keyword);
}
%} %}
@ -607,12 +616,11 @@ block:
} }
| WORD WORD | WORD WORD
{ {
if (!strcmp($1, "break")) $$ = parse_jump($1, $2);
$$ = subst_break($2); }
else if (!strcmp($1, "continue")) | WORD '$'
$$ = subst_continue($2); {
else $$ = parse_jump($1, NULL);
yyerrorf("unknown keyword \"%s\"", $1);
} }
| WORD | WORD
{ {
@ -620,12 +628,8 @@ block:
$$ = subst_end(); $$ = subst_end();
else if (!strcmp($1, "ignore")) else if (!strcmp($1, "ignore"))
$$ = subst_ignore(); $$ = subst_ignore();
else if (!strcmp($1, "break"))
$$ = subst_break(NULL);
else if (!strcmp($1, "continue"))
$$ = subst_continue(NULL);
else else
yyerrorf("unknown keyword \"%s\"", $1); $$ = parse_jump($1, NULL);
} }
; ;