summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-08-21 12:47:58 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-08-24 19:02:56 -0700
commit2d0e3c969830d8462aa2c3cb9255ecf35a4905b5 (patch)
tree9818df187ea686a036d3764ab27321e6f5cce418 /toke.c
parent01e751b2b71ea7b314a35dd6012f98ea469069f6 (diff)
downloadperl-2d0e3c969830d8462aa2c3cb9255ecf35a4905b5.tar.gz
Set PL_expect less often when parsing semicolons
As it worked before, the parser (perly.y) would set PL_expect to XSTATE after encountering a statement-terminating semicolon. Two functions in op.c--package and utilize--had to set the value to XSTATE as a result. Also, in the case of a closing brace, the lexer emits an implicit semicolon followed by '}' (emitted via force_next). force_next records the value of PL_expect and restores it when emitting the token. So in this case the value of PL_expect was flipping back and forth between two values. Instead of having the parser set it to XSTATE, we can have the lexer set it to XSTATE by default when emitting an explicit semicolon. (It was setting it to XTERM.) The parser can set it to XTERM in the only place that matters; viz., the header of a for-loop. This simplifies things conceptually, and makes the code a whole line shorter. (The diff stat shows more savings in line count, but that is because the version of bison I used to regenerate the tables produces smaller headers than what was already committed.)
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/toke.c b/toke.c
index b0e951893a..13c7e934df 100644
--- a/toke.c
+++ b/toke.c
@@ -5379,7 +5379,8 @@ Perl_yylex(pTHX)
TOKEN(0);
CLINE;
s++;
- OPERATOR(';');
+ PL_expect = XSTATE;
+ TOKEN(';');
case ')':
if (!PL_lex_allbrackets && PL_lex_fakeeof >= LEX_FAKEEOF_CLOSING)
TOKEN(0);