This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Set PL_expect less often when parsing semicolons
authorFather Chrysostomos <sprout@cpan.org>
Thu, 21 Aug 2014 19:47:58 +0000 (12:47 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 25 Aug 2014 02:02:56 +0000 (19:02 -0700)
commit2d0e3c969830d8462aa2c3cb9255ecf35a4905b5
tree9818df187ea686a036d3764ab27321e6f5cce418
parent01e751b2b71ea7b314a35dd6012f98ea469069f6
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.)
op.c
perly.act
perly.h
perly.tab
perly.y
toke.c