summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-08-22 06:13:17 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-08-24 19:02:58 -0700
commit5c86b6dfc4a5c74dad9f83a08d08b4536632cda1 (patch)
tree3649921a238463e4cf488051f1501c39570dfb72 /perly.y
parent8f0d8652cd7599dde9c54931b556782c1275ff88 (diff)
downloadperl-5c86b6dfc4a5c74dad9f83a08d08b4536632cda1.tar.gz
Set PL_expect only once after curly subscripts
When curly subscripts are parsed, the lexer (toke.c:yylex) notes that the value of PL_expect needs to be set to XSTATE (expecting a state- ment) after the final brace. When the final brace is encountered, PL_expect is set to that recorded value. But then the parser (perly.y) sets it to XOPERATOR immediately thereafter. This approach requires a plethora of identical statements in perly.y. If we just set PL_expect to the right value to begin with, we can avoid all those assignments.
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y15
1 files changed, 3 insertions, 12 deletions
diff --git a/perly.y b/perly.y
index e3df8319dc..e2f934f4d2 100644
--- a/perly.y
+++ b/perly.y
@@ -680,9 +680,7 @@ method : METHOD
subscripted: gelem '{' expr ';' '}' /* *main::{something} */
/* In this and all the hash accessors, ';' is
* provided by the tokeniser */
- { $$ = newBINOP(OP_GELEM, 0, $1, scalar($3));
- PL_parser->expect = XOPERATOR;
- }
+ { $$ = newBINOP(OP_GELEM, 0, $1, scalar($3)); }
| scalar '[' expr ']' /* $array[$element] */
{ $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3));
}
@@ -698,20 +696,15 @@ subscripted: gelem '{' expr ';' '}' /* *main::{something} */
}
| scalar '{' expr ';' '}' /* $foo{bar();} */
{ $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
- PL_parser->expect = XOPERATOR;
}
| term ARROW '{' expr ';' '}' /* somehref->{bar();} */
{ $$ = newBINOP(OP_HELEM, 0,
ref(newHVREF($1),OP_RV2HV),
- jmaybe($4));
- PL_parser->expect = XOPERATOR;
- }
+ jmaybe($4)); }
| subscripted '{' expr ';' '}' /* $foo->[bar]->{baz;} */
{ $$ = newBINOP(OP_HELEM, 0,
ref(newHVREF($1),OP_RV2HV),
- jmaybe($3));
- PL_parser->expect = XOPERATOR;
- }
+ jmaybe($3)); }
| term ARROW '(' ')' /* $subref->() */
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
newCVREF(0, scalar($1))); }
@@ -886,7 +879,6 @@ term : termbinop
if ($$ && $1)
$$->op_private |=
$1->op_private & OPpSLICEWARNING;
- PL_parser->expect = XOPERATOR;
}
| kvslice '{' expr ';' '}' /* %hash{@keys} */
{ $$ = op_prepend_elem(OP_KVHSLICE,
@@ -897,7 +889,6 @@ term : termbinop
if ($$ && $1)
$$->op_private |=
$1->op_private & OPpSLICEWARNING;
- PL_parser->expect = XOPERATOR;
}
| THING %prec '('
{ $$ = $1; }