diff options
author | Father Chrysostomos <sprout@cpan.org> | 2016-05-21 05:42:55 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2016-05-21 06:07:28 -0700 |
commit | 28383d1aefa4f4c119153a5ed41ebf82ecd7a062 (patch) | |
tree | d6a9b5bd9328d65beb552bf87b2886e4c3fe24d2 /perly.y | |
parent | 76734a3218e712760695898e424c2369ccdd49c6 (diff) | |
download | perl-28383d1aefa4f4c119153a5ed41ebf82ecd7a062.tar.gz |
Simplify parser’s handling of my/local
In Perl 5.000, the same token, LOCAL, was used for both ‘my’ and
‘local’, with a token value, passed to localize() as a second argu-
ment, to distinguish between them.
perl-5.003_07-9-g55497cf (inseparable changes from patch from
perl5.003_07 to perl5.003_08), for no apparent reason, split them into
two tokens, removing the token values and assigning values in perly.y
via $$ = 0 and $$ = 1. They still ultimately made their way through
the same grammar rule, as there was only one localize() call in
perly.y. The code still made sense.
perl-5.005_02-1816-g09bef84 (sub : attrlist) changed things, such that
the tokens are separate *and* they get separate token values assigned
to them. ‘local’ and ‘my’ no longer follow the same grammar rules
in perly.y, so there are separate localize() calls for the different
token types. Hence, the use of a token value to distinguish them does
not make sense. It just makes this more complicated that necessary.
So this commit removes the token values. Since the two token types
follow different paths through perly.y and have separate localize()
calls, we can hard-code the argument to localize() there, instead of
passing the value through from toke.c as a token value.
This does shrink toke.o slightly (for me it went from 876040 to
876000), and it makes this conceptually clearer.
Diffstat (limited to 'perly.y')
-rw-r--r-- | perly.y | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -889,7 +889,7 @@ term : termbinop | myattrterm %prec UNIOP { $$ = $1; } | LOCAL term %prec UNIOP - { $$ = localize($2,$1); } + { $$ = localize($2,0); } | '(' expr ')' { $$ = sawparens($2); } | QWLIST @@ -1040,7 +1040,7 @@ term : termbinop myattrterm: MY myterm myattrlist { $$ = my_attrs($2,$3); } | MY myterm - { $$ = localize($2,$1); } + { $$ = localize($2,1); } ; /* Things that can be "my"'d */ |