From 3d849f133038a22ab4a4a9957092bb4ee0eab37b Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sat, 3 Dec 2016 15:11:11 +0000 Subject: yyparse: replace some gotos with a while(1) loop Just as efficient, and more readable. Welcome to 1970's structured programming! --- perly.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'perly.c') 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. | -- cgit v1.2.1