summaryrefslogtreecommitdiff
path: root/perly.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2016-12-03 15:11:11 +0000
committerDavid Mitchell <davem@iabyn.com>2016-12-05 11:54:03 +0000
commit3d849f133038a22ab4a4a9957092bb4ee0eab37b (patch)
treea3e5f318d4cae6026d91de02e74992831b8c5ac6 /perly.c
parent73f2343123f6b98ed4a0b1fc57fd65e720f38b1b (diff)
downloadperl-3d849f133038a22ab4a4a9957092bb4ee0eab37b.tar.gz
yyparse: replace some gotos with a while(1) loop
Just as efficient, and more readable. Welcome to 1970's structured programming!
Diffstat (limited to 'perly.c')
-rw-r--r--perly.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/perly.c b/perly.c
index ac6112af2f..0aff507f57 100644
--- a/perly.c
+++ b/perly.c
@@ -293,6 +293,7 @@ Perl_yyparse (pTHX_ int gramtype)
`------------------------------------------------------------*/
yynewstate:
+ while (1) {
yystate = ps->state;
YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
@@ -326,7 +327,7 @@ Perl_yyparse (pTHX_ int gramtype)
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
- goto yydefault;
+ break;
/* Not known => get a lookahead token if don't already have one. */
@@ -360,7 +361,8 @@ Perl_yyparse (pTHX_ int gramtype)
* part of the <=YYLAST test for speed */
yyn += yytoken;
if ((unsigned int)yyn > YYLAST || yycheck[yyn] != yytoken)
- goto yydefault;
+ break;
+
yyn = yytable[yyn];
if (yyn <= 0) {
if (yyn == 0 || yyn == YYTABLE_NINF)
@@ -393,18 +395,15 @@ Perl_yyparse (pTHX_ int gramtype)
if (parser->yyerrstatus)
parser->yyerrstatus--;
- goto yynewstate;
+ }
/*-----------------------------------------------------------.
- | yydefault -- do the default action for the current state. |
+ | do the default action for the current state. |
`-----------------------------------------------------------*/
- yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
- goto yyreduce;
-
/*-----------------------------.
| yyreduce -- Do a reduction. |