This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Consolidate some PL_expect assignments
authorFather Chrysostomos <sprout@cpan.org>
Fri, 22 Aug 2014 13:01:45 +0000 (06:01 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 25 Aug 2014 02:02:57 +0000 (19:02 -0700)
The previous commit allows these settings of PL_expect to be combined.
We no longer need one before force_next in each instance.

toke.c

diff --git a/toke.c b/toke.c
index 3595570..d1325b3 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -218,10 +218,9 @@ static const char* const lex_state_names[] = {
 #define PREREF(retval) return (PL_expect = XREF,PL_bufptr = s, REPORT(retval))
 #define TERM(retval) return (CLINE, PL_expect = XOPERATOR, PL_bufptr = s, REPORT(retval))
 #define POSTDEREF(f) return (PL_bufptr = s, S_postderef(aTHX_ REPORT(f),s[1]))
 #define PREREF(retval) return (PL_expect = XREF,PL_bufptr = s, REPORT(retval))
 #define TERM(retval) return (CLINE, PL_expect = XOPERATOR, PL_bufptr = s, REPORT(retval))
 #define POSTDEREF(f) return (PL_bufptr = s, S_postderef(aTHX_ REPORT(f),s[1]))
-#define LOOPX(f) return (PL_expect = XOPERATOR, \
-                        PL_bufptr = force_word(s,WORD,TRUE,FALSE), \
+#define LOOPX(f) return (PL_bufptr = force_word(s,WORD,TRUE,FALSE), \
                         pl_yylval.ival=f, \
                         pl_yylval.ival=f, \
-                        (void)(PL_nexttoke || (PL_expect = XTERM)), \
+                        PL_expect = PL_nexttoke ? XOPERATOR : XTERM, \
                         REPORT((int)LOOPEX))
 #define FTST(f)  return (pl_yylval.ival=f, PL_expect=XTERMORDORDOR, PL_bufptr=s, REPORT((int)UNIOP))
 #define FUN0(f)  return (pl_yylval.ival=f, PL_expect=XOPERATOR, PL_bufptr=s, REPORT((int)FUNC0))
                         REPORT((int)LOOPEX))
 #define FTST(f)  return (pl_yylval.ival=f, PL_expect=XTERMORDORDOR, PL_bufptr=s, REPORT((int)UNIOP))
 #define FUN0(f)  return (pl_yylval.ival=f, PL_expect=XOPERATOR, PL_bufptr=s, REPORT((int)FUNC0))
@@ -7611,7 +7610,6 @@ Perl_yylex(pTHX)
 
        case KEY_require:
            s = SKIPSPACE1(s);
 
        case KEY_require:
            s = SKIPSPACE1(s);
-           PL_expect = XOPERATOR;
            if (isDIGIT(*s)) {
                s = force_version(s, FALSE);
            }
            if (isDIGIT(*s)) {
                s = force_version(s, FALSE);
            }
@@ -7632,7 +7630,7 @@ Perl_yylex(pTHX)
            }
            else 
                pl_yylval.ival = 0;
            }
            else 
                pl_yylval.ival = 0;
-           if (!PL_nexttoke) PL_expect = XTERM;
+           PL_expect = PL_nexttoke ? XOPERATOR : XTERM;
            PL_bufptr = s;
            PL_last_uni = PL_oldbufptr;
            PL_last_lop_op = OP_REQUIRE;
            PL_bufptr = s;
            PL_last_uni = PL_oldbufptr;
            PL_last_lop_op = OP_REQUIRE;