This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
OP_TRANS: change extended table format
[perl5.git] / perly.y
... / ...
CommitLineData
1/* perly.y
2 *
3 * Copyright (c) 1991-2002, 2003, 2004, 2005, 2006 Larry Wall
4 * Copyright (c) 2007, 2008, 2009, 2010, 2011 by Larry Wall and others
5 *
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
8 *
9 */
10
11/*
12 * 'I see,' laughed Strider. 'I look foul and feel fair. Is that it?
13 * All that is gold does not glitter, not all those who wander are lost.'
14 *
15 * [p.171 of _The Lord of the Rings_, I/x: "Strider"]
16 */
17
18/*
19 * This file holds the grammar for the Perl language. If edited, you need
20 * to run regen_perly.pl, which re-creates the files perly.h, perly.tab
21 * and perly.act which are derived from this.
22 *
23 * The main job of of this grammar is to call the various newFOO()
24 * functions in op.c to build a syntax tree of OP structs.
25 * It relies on the lexer in toke.c to do the tokenizing.
26 *
27 * Note: due to the way that the cleanup code works WRT to freeing ops on
28 * the parse stack, it is dangerous to assign to the $n variables within
29 * an action.
30 */
31
32/* Make the parser re-entrant. */
33
34%pure-parser
35
36%start grammar
37
38%union {
39 I32 ival; /* __DEFAULT__ (marker for regen_perly.pl;
40 must always be 1st union member) */
41 char *pval;
42 OP *opval;
43 GV *gvval;
44}
45
46%token <ival> GRAMPROG GRAMEXPR GRAMBLOCK GRAMBARESTMT GRAMFULLSTMT GRAMSTMTSEQ
47
48%token <ival> '{' '}' '[' ']' '-' '+' '@' '%' '&' '=' '.'
49
50%token <opval> BAREWORD METHOD FUNCMETH THING PMFUNC PRIVATEREF QWLIST
51%token <opval> FUNC0OP FUNC0SUB UNIOPSUB LSTOPSUB
52%token <opval> PLUGEXPR PLUGSTMT
53%token <pval> LABEL
54%token <ival> FORMAT SUB ANONSUB PACKAGE USE
55%token <ival> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
56%token <ival> GIVEN WHEN DEFAULT
57%token <ival> LOOPEX DOTDOT YADAYADA
58%token <ival> FUNC0 FUNC1 FUNC UNIOP LSTOP
59%token <ival> RELOP EQOP MULOP ADDOP
60%token <ival> DOLSHARP DO HASHBRACK NOAMP
61%token <ival> LOCAL MY REQUIRE
62%token <ival> COLONATTR FORMLBRACK FORMRBRACK
63
64%type <ival> grammar remember mremember
65%type <ival> startsub startanonsub startformsub
66
67%type <ival> mintro
68
69%type <opval> stmtseq fullstmt labfullstmt barestmt block mblock else
70%type <opval> expr term subscripted scalar ary hsh arylen star amper sideff
71%type <opval> sliceme kvslice gelem
72%type <opval> listexpr nexpr texpr iexpr mexpr mnexpr
73%type <opval> optlistexpr optexpr optrepl indirob listop method
74%type <opval> formname subname proto optsubbody cont my_scalar my_var
75%type <opval> refgen_topic formblock
76%type <opval> subattrlist myattrlist myattrterm myterm
77%type <opval> termbinop termunop anonymous termdo
78%type <ival> sigslurpsigil
79%type <opval> sigvarname sigdefault sigscalarelem sigslurpelem
80%type <opval> sigelem siglist siglistornull subsignature
81%type <opval> formstmtseq formline formarg
82
83%nonassoc <ival> PREC_LOW
84%nonassoc LOOPEX
85
86%left <ival> OROP DOROP
87%left <ival> ANDOP
88%right <ival> NOTOP
89%nonassoc LSTOP LSTOPSUB
90%left <ival> ','
91%right <ival> ASSIGNOP
92%right <ival> '?' ':'
93%nonassoc DOTDOT
94%left <ival> OROR DORDOR
95%left <ival> ANDAND
96%left <ival> BITOROP
97%left <ival> BITANDOP
98%nonassoc EQOP
99%nonassoc RELOP
100%nonassoc UNIOP UNIOPSUB
101%nonassoc REQUIRE
102%left <ival> SHIFTOP
103%left ADDOP
104%left MULOP
105%left <ival> MATCHOP
106%right <ival> '!' '~' UMINUS REFGEN
107%right <ival> POWOP
108%nonassoc <ival> PREINC PREDEC POSTINC POSTDEC POSTJOIN
109%left <ival> ARROW
110%nonassoc <ival> ')'
111%left <ival> '('
112%left '[' '{'
113
114%% /* RULES */
115
116/* Top-level choice of what kind of thing yyparse was called to parse */
117grammar : GRAMPROG
118 {
119 parser->expect = XSTATE;
120 $<ival>$ = 0;
121 }
122 remember stmtseq
123 {
124 newPROG(block_end($3,$4));
125 PL_compiling.cop_seq = 0;
126 $$ = 0;
127 }
128 | GRAMEXPR
129 {
130 parser->expect = XTERM;
131 $<ival>$ = 0;
132 }
133 optexpr
134 {
135 PL_eval_root = $3;
136 $$ = 0;
137 }
138 | GRAMBLOCK
139 {
140 parser->expect = XBLOCK;
141 $<ival>$ = 0;
142 }
143 block
144 {
145 PL_pad_reset_pending = TRUE;
146 PL_eval_root = $3;
147 $$ = 0;
148 yyunlex();
149 parser->yychar = yytoken = YYEOF;
150 }
151 | GRAMBARESTMT
152 {
153 parser->expect = XSTATE;
154 $<ival>$ = 0;
155 }
156 barestmt
157 {
158 PL_pad_reset_pending = TRUE;
159 PL_eval_root = $3;
160 $$ = 0;
161 yyunlex();
162 parser->yychar = yytoken = YYEOF;
163 }
164 | GRAMFULLSTMT
165 {
166 parser->expect = XSTATE;
167 $<ival>$ = 0;
168 }
169 fullstmt
170 {
171 PL_pad_reset_pending = TRUE;
172 PL_eval_root = $3;
173 $$ = 0;
174 yyunlex();
175 parser->yychar = yytoken = YYEOF;
176 }
177 | GRAMSTMTSEQ
178 {
179 parser->expect = XSTATE;
180 $<ival>$ = 0;
181 }
182 stmtseq
183 {
184 PL_eval_root = $3;
185 $$ = 0;
186 }
187 ;
188
189/* An ordinary block */
190block : '{' remember stmtseq '}'
191 { if (parser->copline > (line_t)$1)
192 parser->copline = (line_t)$1;
193 $$ = block_end($2, $3);
194 }
195 ;
196
197/* format body */
198formblock: '=' remember ';' FORMRBRACK formstmtseq ';' '.'
199 { if (parser->copline > (line_t)$1)
200 parser->copline = (line_t)$1;
201 $$ = block_end($2, $5);
202 }
203 ;
204
205remember: /* NULL */ /* start a full lexical scope */
206 { $$ = block_start(TRUE);
207 parser->parsed_sub = 0; }
208 ;
209
210mblock : '{' mremember stmtseq '}'
211 { if (parser->copline > (line_t)$1)
212 parser->copline = (line_t)$1;
213 $$ = block_end($2, $3);
214 }
215 ;
216
217mremember: /* NULL */ /* start a partial lexical scope */
218 { $$ = block_start(FALSE);
219 parser->parsed_sub = 0; }
220 ;
221
222/* A sequence of statements in the program */
223stmtseq : /* NULL */
224 { $$ = NULL; }
225 | stmtseq fullstmt
226 { $$ = op_append_list(OP_LINESEQ, $1, $2);
227 PL_pad_reset_pending = TRUE;
228 if ($1 && $2)
229 PL_hints |= HINT_BLOCK_SCOPE;
230 }
231 ;
232
233/* A sequence of format lines */
234formstmtseq: /* NULL */
235 { $$ = NULL; }
236 | formstmtseq formline
237 { $$ = op_append_list(OP_LINESEQ, $1, $2);
238 PL_pad_reset_pending = TRUE;
239 if ($1 && $2)
240 PL_hints |= HINT_BLOCK_SCOPE;
241 }
242 ;
243
244/* A statement in the program, including optional labels */
245fullstmt: barestmt
246 {
247 $$ = $1 ? newSTATEOP(0, NULL, $1) : NULL;
248 }
249 | labfullstmt
250 { $$ = $1; }
251 ;
252
253labfullstmt: LABEL barestmt
254 {
255 $$ = newSTATEOP(SVf_UTF8 * $1[strlen($1)+1], $1, $2);
256 }
257 | LABEL labfullstmt
258 {
259 $$ = newSTATEOP(SVf_UTF8 * $1[strlen($1)+1], $1, $2);
260 }
261 ;
262
263/* A bare statement, lacking label and other aspects of state op */
264barestmt: PLUGSTMT
265 { $$ = $1; }
266 | FORMAT startformsub formname formblock
267 {
268 CV *fmtcv = PL_compcv;
269 newFORM($2, $3, $4);
270 $$ = NULL;
271 if (CvOUTSIDE(fmtcv) && !CvEVAL(CvOUTSIDE(fmtcv))) {
272 pad_add_weakref(fmtcv);
273 }
274 parser->parsed_sub = 1;
275 }
276 | SUB subname startsub
277 {
278 if ($2->op_type == OP_CONST) {
279 const char *const name =
280 SvPV_nolen_const(((SVOP*)$2)->op_sv);
281 if (strEQ(name, "BEGIN") || strEQ(name, "END")
282 || strEQ(name, "INIT") || strEQ(name, "CHECK")
283 || strEQ(name, "UNITCHECK"))
284 CvSPECIAL_on(PL_compcv);
285 }
286 else
287 /* State subs inside anonymous subs need to be
288 clonable themselves. */
289 if (CvANON(CvOUTSIDE(PL_compcv))
290 || CvCLONE(CvOUTSIDE(PL_compcv))
291 || !PadnameIsSTATE(PadlistNAMESARRAY(CvPADLIST(
292 CvOUTSIDE(PL_compcv)
293 ))[$2->op_targ]))
294 CvCLONE_on(PL_compcv);
295 parser->in_my = 0;
296 parser->in_my_stash = NULL;
297 }
298 proto subattrlist optsubbody
299 {
300 SvREFCNT_inc_simple_void(PL_compcv);
301 $2->op_type == OP_CONST
302 ? newATTRSUB($3, $2, $5, $6, $7)
303 : newMYSUB($3, $2, $5, $6, $7)
304 ;
305 $$ = NULL;
306 intro_my();
307 parser->parsed_sub = 1;
308 }
309 | SUB subname startsub
310 {
311 if ($2->op_type == OP_CONST) {
312 const char *const name =
313 SvPV_nolen_const(((SVOP*)$2)->op_sv);
314 if (strEQ(name, "BEGIN") || strEQ(name, "END")
315 || strEQ(name, "INIT") || strEQ(name, "CHECK")
316 || strEQ(name, "UNITCHECK"))
317 CvSPECIAL_on(PL_compcv);
318 }
319 else
320 /* State subs inside anonymous subs need to be
321 clonable themselves. */
322 if (CvANON(CvOUTSIDE(PL_compcv))
323 || CvCLONE(CvOUTSIDE(PL_compcv))
324 || !PadnameIsSTATE(PadlistNAMESARRAY(CvPADLIST(
325 CvOUTSIDE(PL_compcv)
326 ))[$2->op_targ]))
327 CvCLONE_on(PL_compcv);
328 parser->in_my = 0;
329 parser->in_my_stash = NULL;
330 }
331 remember subsignature subattrlist '{' stmtseq '}'
332 {
333 OP *body;
334 if (parser->copline > (line_t)$8)
335 parser->copline = (line_t)$8;
336 body = block_end($5,
337 op_append_list(OP_LINESEQ, $6, $9));
338
339 SvREFCNT_inc_simple_void(PL_compcv);
340 $2->op_type == OP_CONST
341 ? newATTRSUB($3, $2, NULL, $7, body)
342 : newMYSUB($3, $2, NULL, $7, body)
343 ;
344 $$ = NULL;
345 intro_my();
346 parser->parsed_sub = 1;
347 }
348 | PACKAGE BAREWORD BAREWORD ';'
349 {
350 package($3);
351 if ($2)
352 package_version($2);
353 $$ = NULL;
354 }
355 | USE startsub
356 { CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ }
357 BAREWORD BAREWORD optlistexpr ';'
358 {
359 SvREFCNT_inc_simple_void(PL_compcv);
360 utilize($1, $2, $4, $5, $6);
361 parser->parsed_sub = 1;
362 $$ = NULL;
363 }
364 | IF '(' remember mexpr ')' mblock else
365 {
366 $$ = block_end($3,
367 newCONDOP(0, $4, op_scope($6), $7));
368 parser->copline = (line_t)$1;
369 }
370 | UNLESS '(' remember mexpr ')' mblock else
371 {
372 $$ = block_end($3,
373 newCONDOP(0, $4, $7, op_scope($6)));
374 parser->copline = (line_t)$1;
375 }
376 | GIVEN '(' remember mexpr ')' mblock
377 {
378 $$ = block_end($3, newGIVENOP($4, op_scope($6), 0));
379 parser->copline = (line_t)$1;
380 }
381 | WHEN '(' remember mexpr ')' mblock
382 { $$ = block_end($3, newWHENOP($4, op_scope($6))); }
383 | DEFAULT block
384 { $$ = newWHENOP(0, op_scope($2)); }
385 | WHILE '(' remember texpr ')' mintro mblock cont
386 {
387 $$ = block_end($3,
388 newWHILEOP(0, 1, NULL,
389 $4, $7, $8, $6));
390 parser->copline = (line_t)$1;
391 }
392 | UNTIL '(' remember iexpr ')' mintro mblock cont
393 {
394 $$ = block_end($3,
395 newWHILEOP(0, 1, NULL,
396 $4, $7, $8, $6));
397 parser->copline = (line_t)$1;
398 }
399 | FOR '(' remember mnexpr ';'
400 { parser->expect = XTERM; }
401 texpr ';'
402 { parser->expect = XTERM; }
403 mintro mnexpr ')'
404 mblock
405 {
406 OP *initop = $4;
407 OP *forop = newWHILEOP(0, 1, NULL,
408 scalar($7), $13, $11, $10);
409 if (initop) {
410 forop = op_prepend_elem(OP_LINESEQ, initop,
411 op_append_elem(OP_LINESEQ,
412 newOP(OP_UNSTACK, OPf_SPECIAL),
413 forop));
414 }
415 PL_hints |= HINT_BLOCK_SCOPE;
416 $$ = block_end($3, forop);
417 parser->copline = (line_t)$1;
418 }
419 | FOR MY remember my_scalar '(' mexpr ')' mblock cont
420 {
421 $$ = block_end($3, newFOROP(0, $4, $6, $8, $9));
422 parser->copline = (line_t)$1;
423 }
424 | FOR scalar '(' remember mexpr ')' mblock cont
425 {
426 $$ = block_end($4, newFOROP(0,
427 op_lvalue($2, OP_ENTERLOOP), $5, $7, $8));
428 parser->copline = (line_t)$1;
429 }
430 | FOR my_refgen remember my_var
431 { parser->in_my = 0; $<opval>$ = my($4); }
432 '(' mexpr ')' mblock cont
433 {
434 $$ = block_end(
435 $3,
436 newFOROP(0,
437 op_lvalue(
438 newUNOP(OP_REFGEN, 0,
439 $<opval>5),
440 OP_ENTERLOOP),
441 $7, $9, $10)
442 );
443 parser->copline = (line_t)$1;
444 }
445 | FOR REFGEN refgen_topic '(' remember mexpr ')' mblock cont
446 {
447 $$ = block_end($5, newFOROP(
448 0, op_lvalue(newUNOP(OP_REFGEN, 0,
449 $3),
450 OP_ENTERLOOP), $6, $8, $9));
451 parser->copline = (line_t)$1;
452 }
453 | FOR '(' remember mexpr ')' mblock cont
454 {
455 $$ = block_end($3,
456 newFOROP(0, NULL, $4, $6, $7));
457 parser->copline = (line_t)$1;
458 }
459 | block cont
460 {
461 /* a block is a loop that happens once */
462 $$ = newWHILEOP(0, 1, NULL,
463 NULL, $1, $2, 0);
464 }
465 | PACKAGE BAREWORD BAREWORD '{' remember
466 {
467 package($3);
468 if ($2) {
469 package_version($2);
470 }
471 }
472 stmtseq '}'
473 {
474 /* a block is a loop that happens once */
475 $$ = newWHILEOP(0, 1, NULL,
476 NULL, block_end($5, $7), NULL, 0);
477 if (parser->copline > (line_t)$4)
478 parser->copline = (line_t)$4;
479 }
480 | sideff ';'
481 {
482 $$ = $1;
483 }
484 | YADAYADA ';'
485 {
486 $$ = newLISTOP(OP_DIE, 0, newOP(OP_PUSHMARK, 0),
487 newSVOP(OP_CONST, 0, newSVpvs("Unimplemented")));
488 }
489 | ';'
490 {
491 $$ = NULL;
492 parser->copline = NOLINE;
493 }
494 ;
495
496/* Format line */
497formline: THING formarg
498 { OP *list;
499 if ($2) {
500 OP *term = $2;
501 list = op_append_elem(OP_LIST, $1, term);
502 }
503 else {
504 list = $1;
505 }
506 if (parser->copline == NOLINE)
507 parser->copline = CopLINE(PL_curcop)-1;
508 else parser->copline--;
509 $$ = newSTATEOP(0, NULL,
510 op_convert_list(OP_FORMLINE, 0, list));
511 }
512 ;
513
514formarg : /* NULL */
515 { $$ = NULL; }
516 | FORMLBRACK stmtseq FORMRBRACK
517 { $$ = op_unscope($2); }
518 ;
519
520/* An expression which may have a side-effect */
521sideff : error
522 { $$ = NULL; }
523 | expr
524 { $$ = $1; }
525 | expr IF expr
526 { $$ = newLOGOP(OP_AND, 0, $3, $1); }
527 | expr UNLESS expr
528 { $$ = newLOGOP(OP_OR, 0, $3, $1); }
529 | expr WHILE expr
530 { $$ = newLOOPOP(OPf_PARENS, 1, scalar($3), $1); }
531 | expr UNTIL iexpr
532 { $$ = newLOOPOP(OPf_PARENS, 1, $3, $1); }
533 | expr FOR expr
534 { $$ = newFOROP(0, NULL, $3, $1, NULL);
535 parser->copline = (line_t)$2; }
536 | expr WHEN expr
537 { $$ = newWHENOP($3, op_scope($1)); }
538 ;
539
540/* else and elsif blocks */
541else : /* NULL */
542 { $$ = NULL; }
543 | ELSE mblock
544 {
545 ($2)->op_flags |= OPf_PARENS;
546 $$ = op_scope($2);
547 }
548 | ELSIF '(' mexpr ')' mblock else
549 { parser->copline = (line_t)$1;
550 $$ = newCONDOP(0,
551 newSTATEOP(OPf_SPECIAL,NULL,$3),
552 op_scope($5), $6);
553 PL_hints |= HINT_BLOCK_SCOPE;
554 }
555 ;
556
557/* Continue blocks */
558cont : /* NULL */
559 { $$ = NULL; }
560 | CONTINUE block
561 { $$ = op_scope($2); }
562 ;
563
564/* determine whether there are any new my declarations */
565mintro : /* NULL */
566 { $$ = (PL_min_intro_pending &&
567 PL_max_intro_pending >= PL_min_intro_pending);
568 intro_my(); }
569
570/* Normal expression */
571nexpr : /* NULL */
572 { $$ = NULL; }
573 | sideff
574 ;
575
576/* Boolean expression */
577texpr : /* NULL means true */
578 { YYSTYPE tmplval;
579 (void)scan_num("1", &tmplval);
580 $$ = tmplval.opval; }
581 | expr
582 ;
583
584/* Inverted boolean expression */
585iexpr : expr
586 { $$ = invert(scalar($1)); }
587 ;
588
589/* Expression with its own lexical scope */
590mexpr : expr
591 { $$ = $1; intro_my(); }
592 ;
593
594mnexpr : nexpr
595 { $$ = $1; intro_my(); }
596 ;
597
598formname: BAREWORD { $$ = $1; }
599 | /* NULL */ { $$ = NULL; }
600 ;
601
602startsub: /* NULL */ /* start a regular subroutine scope */
603 { $$ = start_subparse(FALSE, 0);
604 SAVEFREESV(PL_compcv); }
605
606 ;
607
608startanonsub: /* NULL */ /* start an anonymous subroutine scope */
609 { $$ = start_subparse(FALSE, CVf_ANON);
610 SAVEFREESV(PL_compcv); }
611 ;
612
613startformsub: /* NULL */ /* start a format subroutine scope */
614 { $$ = start_subparse(TRUE, 0);
615 SAVEFREESV(PL_compcv); }
616 ;
617
618/* Name of a subroutine - must be a bareword, could be special */
619subname : BAREWORD
620 | PRIVATEREF
621 ;
622
623/* Subroutine prototype */
624proto : /* NULL */
625 { $$ = NULL; }
626 | THING
627 ;
628
629/* Optional list of subroutine attributes */
630subattrlist: /* NULL */
631 { $$ = NULL; }
632 | COLONATTR THING
633 { $$ = $2; }
634 | COLONATTR
635 { $$ = NULL; }
636 ;
637
638/* List of attributes for a "my" variable declaration */
639myattrlist: COLONATTR THING
640 { $$ = $2; }
641 | COLONATTR
642 { $$ = NULL; }
643 ;
644
645
646
647/* --------------------------------------
648 * subroutine signature parsing
649 */
650
651/* the '' or 'foo' part of a '$' or '@foo' etc signature variable */
652sigvarname: /* NULL */
653 { parser->in_my = 0; $$ = NULL; }
654 | PRIVATEREF
655 { parser->in_my = 0; $$ = $1; }
656 ;
657
658sigslurpsigil:
659 '@'
660 { $$ = '@'; }
661 | '%'
662 { $$ = '%'; }
663
664/* @, %, @foo, %foo */
665sigslurpelem: sigslurpsigil sigvarname sigdefault/* def only to catch errors */
666 {
667 I32 sigil = $1;
668 OP *var = $2;
669 OP *defexpr = $3;
670
671 if (parser->sig_slurpy)
672 yyerror("Multiple slurpy parameters not allowed");
673 parser->sig_slurpy = (char)sigil;
674
675 if (defexpr)
676 yyerror("A slurpy parameter may not have "
677 "a default value");
678
679 $$ = var ? newSTATEOP(0, NULL, var) : NULL;
680 }
681 ;
682
683/* default part of sub signature scalar element: i.e. '= default_expr' */
684sigdefault: /* NULL */
685 { $$ = NULL; }
686 | ASSIGNOP
687 { $$ = newOP(OP_NULL, 0); }
688 | ASSIGNOP term
689 { $$ = $2; }
690
691
692/* subroutine signature scalar element: e.g. '$x', '$=', '$x = $default' */
693sigscalarelem:
694 '$' sigvarname sigdefault
695 {
696 OP *var = $2;
697 OP *defexpr = $3;
698
699 if (parser->sig_slurpy)
700 yyerror("Slurpy parameter not last");
701
702 parser->sig_elems++;
703
704 if (defexpr) {
705 parser->sig_optelems++;
706
707 if ( defexpr->op_type == OP_NULL
708 && !(defexpr->op_flags & OPf_KIDS))
709 {
710 /* handle '$=' special case */
711 if (var)
712 yyerror("Optional parameter "
713 "lacks default expression");
714 op_free(defexpr);
715 }
716 else {
717 /* a normal '=default' expression */
718 OP *defop = (OP*)alloc_LOGOP(OP_ARGDEFELEM,
719 defexpr,
720 LINKLIST(defexpr));
721 /* re-purpose op_targ to hold @_ index */
722 defop->op_targ =
723 (PADOFFSET)(parser->sig_elems - 1);
724
725 if (var) {
726 var->op_flags |= OPf_STACKED;
727 (void)op_sibling_splice(var,
728 NULL, 0, defop);
729 scalar(defop);
730 }
731 else
732 var = newUNOP(OP_NULL, 0, defop);
733
734 LINKLIST(var);
735 /* NB: normally the first child of a
736 * logop is executed before the logop,
737 * and it pushes a boolean result
738 * ready for the logop. For ARGDEFELEM,
739 * the op itself does the boolean
740 * calculation, so set the first op to
741 * it instead.
742 */
743 var->op_next = defop;
744 defexpr->op_next = var;
745 }
746 }
747 else {
748 if (parser->sig_optelems)
749 yyerror("Mandatory parameter "
750 "follows optional parameter");
751 }
752
753 $$ = var ? newSTATEOP(0, NULL, var) : NULL;
754 }
755 ;
756
757
758/* subroutine signature element: e.g. '$x = $default' or '%h' */
759sigelem: sigscalarelem
760 { parser->in_my = KEY_sigvar; $$ = $1; }
761 | sigslurpelem
762 { parser->in_my = KEY_sigvar; $$ = $1; }
763 ;
764
765/* list of subroutine signature elements */
766siglist:
767 siglist ','
768 { $$ = $1; }
769 | siglist ',' sigelem
770 {
771 $$ = op_append_list(OP_LINESEQ, $1, $3);
772 }
773 | sigelem %prec PREC_LOW
774 { $$ = $1; }
775 ;
776
777/* () or (....) */
778siglistornull: /* NULL */
779 { $$ = NULL; }
780 | siglist
781 { $$ = $1; }
782
783/* Subroutine signature */
784subsignature: '('
785 {
786 ENTER;
787 SAVEIV(parser->sig_elems);
788 SAVEIV(parser->sig_optelems);
789 SAVEI8(parser->sig_slurpy);
790 parser->sig_elems = 0;
791 parser->sig_optelems = 0;
792 parser->sig_slurpy = 0;
793 parser->in_my = KEY_sigvar;
794 }
795 siglistornull
796 ')'
797 {
798 OP *sigops = $3;
799 UNOP_AUX_item *aux;
800 OP *check;
801
802 if (!parser->error_count) {
803 assert(FEATURE_SIGNATURES_IS_ENABLED);
804 }
805
806 /* We shouldn't get here otherwise */
807 Perl_ck_warner_d(aTHX_
808 packWARN(WARN_EXPERIMENTAL__SIGNATURES),
809 "The signatures feature is experimental");
810
811 aux = (UNOP_AUX_item*)PerlMemShared_malloc(
812 sizeof(UNOP_AUX_item) * 3);
813 aux[0].iv = parser->sig_elems;
814 aux[1].iv = parser->sig_optelems;
815 aux[2].iv = parser->sig_slurpy;
816 check = newUNOP_AUX(OP_ARGCHECK, 0, NULL, aux);
817 sigops = op_prepend_elem(OP_LINESEQ, check, sigops);
818 sigops = op_prepend_elem(OP_LINESEQ,
819 newSTATEOP(0, NULL, NULL),
820 sigops);
821 /* a nextstate at the end handles context
822 * correctly for an empty sub body */
823 $$ = op_append_elem(OP_LINESEQ,
824 sigops,
825 newSTATEOP(0, NULL, NULL));
826
827 parser->in_my = 0;
828 parser->expect = XATTRBLOCK;
829 LEAVE;
830 }
831 ;
832
833
834
835/* Optional subroutine body, for named subroutine declaration */
836optsubbody: block
837 | ';' { $$ = NULL; }
838 ;
839
840/* Ordinary expressions; logical combinations */
841expr : expr ANDOP expr
842 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
843 | expr OROP expr
844 { $$ = newLOGOP($2, 0, $1, $3); }
845 | expr DOROP expr
846 { $$ = newLOGOP(OP_DOR, 0, $1, $3); }
847 | listexpr %prec PREC_LOW
848 ;
849
850/* Expressions are a list of terms joined by commas */
851listexpr: listexpr ','
852 { $$ = $1; }
853 | listexpr ',' term
854 {
855 OP* term = $3;
856 $$ = op_append_elem(OP_LIST, $1, term);
857 }
858 | term %prec PREC_LOW
859 ;
860
861/* List operators */
862listop : LSTOP indirob listexpr /* map {...} @args or print $fh @args */
863 { $$ = op_convert_list($1, OPf_STACKED,
864 op_prepend_elem(OP_LIST, newGVREF($1,$2), $3) );
865 }
866 | FUNC '(' indirob expr ')' /* print ($fh @args */
867 { $$ = op_convert_list($1, OPf_STACKED,
868 op_prepend_elem(OP_LIST, newGVREF($1,$3), $4) );
869 }
870 | term ARROW method '(' optexpr ')' /* $foo->bar(list) */
871 { $$ = op_convert_list(OP_ENTERSUB, OPf_STACKED,
872 op_append_elem(OP_LIST,
873 op_prepend_elem(OP_LIST, scalar($1), $5),
874 newMETHOP(OP_METHOD, 0, $3)));
875 }
876 | term ARROW method /* $foo->bar */
877 { $$ = op_convert_list(OP_ENTERSUB, OPf_STACKED,
878 op_append_elem(OP_LIST, scalar($1),
879 newMETHOP(OP_METHOD, 0, $3)));
880 }
881 | METHOD indirob optlistexpr /* new Class @args */
882 { $$ = op_convert_list(OP_ENTERSUB, OPf_STACKED,
883 op_append_elem(OP_LIST,
884 op_prepend_elem(OP_LIST, $2, $3),
885 newMETHOP(OP_METHOD, 0, $1)));
886 }
887 | FUNCMETH indirob '(' optexpr ')' /* method $object (@args) */
888 { $$ = op_convert_list(OP_ENTERSUB, OPf_STACKED,
889 op_append_elem(OP_LIST,
890 op_prepend_elem(OP_LIST, $2, $4),
891 newMETHOP(OP_METHOD, 0, $1)));
892 }
893 | LSTOP optlistexpr /* print @args */
894 { $$ = op_convert_list($1, 0, $2); }
895 | FUNC '(' optexpr ')' /* print (@args) */
896 { $$ = op_convert_list($1, 0, $3); }
897 | LSTOPSUB startanonsub block /* sub f(&@); f { foo } ... */
898 { SvREFCNT_inc_simple_void(PL_compcv);
899 $<opval>$ = newANONATTRSUB($2, 0, NULL, $3); }
900 optlistexpr %prec LSTOP /* ... @bar */
901 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
902 op_append_elem(OP_LIST,
903 op_prepend_elem(OP_LIST, $<opval>4, $5), $1));
904 }
905 ;
906
907/* Names of methods. May use $object->$methodname */
908method : METHOD
909 | scalar
910 ;
911
912/* Some kind of subscripted expression */
913subscripted: gelem '{' expr ';' '}' /* *main::{something} */
914 /* In this and all the hash accessors, ';' is
915 * provided by the tokeniser */
916 { $$ = newBINOP(OP_GELEM, 0, $1, scalar($3)); }
917 | scalar '[' expr ']' /* $array[$element] */
918 { $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3));
919 }
920 | term ARROW '[' expr ']' /* somearef->[$element] */
921 { $$ = newBINOP(OP_AELEM, 0,
922 ref(newAVREF($1),OP_RV2AV),
923 scalar($4));
924 }
925 | subscripted '[' expr ']' /* $foo->[$bar]->[$baz] */
926 { $$ = newBINOP(OP_AELEM, 0,
927 ref(newAVREF($1),OP_RV2AV),
928 scalar($3));
929 }
930 | scalar '{' expr ';' '}' /* $foo{bar();} */
931 { $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
932 }
933 | term ARROW '{' expr ';' '}' /* somehref->{bar();} */
934 { $$ = newBINOP(OP_HELEM, 0,
935 ref(newHVREF($1),OP_RV2HV),
936 jmaybe($4)); }
937 | subscripted '{' expr ';' '}' /* $foo->[bar]->{baz;} */
938 { $$ = newBINOP(OP_HELEM, 0,
939 ref(newHVREF($1),OP_RV2HV),
940 jmaybe($3)); }
941 | term ARROW '(' ')' /* $subref->() */
942 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
943 newCVREF(0, scalar($1)));
944 if (parser->expect == XBLOCK)
945 parser->expect = XOPERATOR;
946 }
947 | term ARROW '(' expr ')' /* $subref->(@args) */
948 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
949 op_append_elem(OP_LIST, $4,
950 newCVREF(0, scalar($1))));
951 if (parser->expect == XBLOCK)
952 parser->expect = XOPERATOR;
953 }
954
955 | subscripted '(' expr ')' /* $foo->{bar}->(@args) */
956 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
957 op_append_elem(OP_LIST, $3,
958 newCVREF(0, scalar($1))));
959 if (parser->expect == XBLOCK)
960 parser->expect = XOPERATOR;
961 }
962 | subscripted '(' ')' /* $foo->{bar}->() */
963 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
964 newCVREF(0, scalar($1)));
965 if (parser->expect == XBLOCK)
966 parser->expect = XOPERATOR;
967 }
968 | '(' expr ')' '[' expr ']' /* list slice */
969 { $$ = newSLICEOP(0, $5, $2); }
970 | QWLIST '[' expr ']' /* list literal slice */
971 { $$ = newSLICEOP(0, $3, $1); }
972 | '(' ')' '[' expr ']' /* empty list slice! */
973 { $$ = newSLICEOP(0, $4, NULL); }
974 ;
975
976/* Binary operators between terms */
977termbinop: term ASSIGNOP term /* $x = $y, $x += $y */
978 { $$ = newASSIGNOP(OPf_STACKED, $1, $2, $3); }
979 | term POWOP term /* $x ** $y */
980 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
981 | term MULOP term /* $x * $y, $x x $y */
982 { if ($2 != OP_REPEAT)
983 scalar($1);
984 $$ = newBINOP($2, 0, $1, scalar($3));
985 }
986 | term ADDOP term /* $x + $y */
987 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
988 | term SHIFTOP term /* $x >> $y, $x << $y */
989 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
990 | term RELOP term /* $x > $y, etc. */
991 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
992 | term EQOP term /* $x == $y, $x eq $y */
993 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
994 | term BITANDOP term /* $x & $y */
995 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
996 | term BITOROP term /* $x | $y */
997 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
998 | term DOTDOT term /* $x..$y, $x...$y */
999 { $$ = newRANGE($2, scalar($1), scalar($3)); }
1000 | term ANDAND term /* $x && $y */
1001 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
1002 | term OROR term /* $x || $y */
1003 { $$ = newLOGOP(OP_OR, 0, $1, $3); }
1004 | term DORDOR term /* $x // $y */
1005 { $$ = newLOGOP(OP_DOR, 0, $1, $3); }
1006 | term MATCHOP term /* $x =~ /$y/ */
1007 { $$ = bind_match($2, $1, $3); }
1008 ;
1009
1010/* Unary operators and terms */
1011termunop : '-' term %prec UMINUS /* -$x */
1012 { $$ = newUNOP(OP_NEGATE, 0, scalar($2)); }
1013 | '+' term %prec UMINUS /* +$x */
1014 { $$ = $2; }
1015
1016 | '!' term /* !$x */
1017 { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
1018 | '~' term /* ~$x */
1019 { $$ = newUNOP($1, 0, scalar($2)); }
1020 | term POSTINC /* $x++ */
1021 { $$ = newUNOP(OP_POSTINC, 0,
1022 op_lvalue(scalar($1), OP_POSTINC)); }
1023 | term POSTDEC /* $x-- */
1024 { $$ = newUNOP(OP_POSTDEC, 0,
1025 op_lvalue(scalar($1), OP_POSTDEC));}
1026 | term POSTJOIN /* implicit join after interpolated ->@ */
1027 { $$ = op_convert_list(OP_JOIN, 0,
1028 op_append_elem(
1029 OP_LIST,
1030 newSVREF(scalar(
1031 newSVOP(OP_CONST,0,
1032 newSVpvs("\""))
1033 )),
1034 $1
1035 ));
1036 }
1037 | PREINC term /* ++$x */
1038 { $$ = newUNOP(OP_PREINC, 0,
1039 op_lvalue(scalar($2), OP_PREINC)); }
1040 | PREDEC term /* --$x */
1041 { $$ = newUNOP(OP_PREDEC, 0,
1042 op_lvalue(scalar($2), OP_PREDEC)); }
1043
1044 ;
1045
1046/* Constructors for anonymous data */
1047anonymous: '[' expr ']'
1048 { $$ = newANONLIST($2); }
1049 | '[' ']'
1050 { $$ = newANONLIST(NULL);}
1051 | HASHBRACK expr ';' '}' %prec '(' /* { foo => "Bar" } */
1052 { $$ = newANONHASH($2); }
1053 | HASHBRACK ';' '}' %prec '(' /* { } (';' by tokener) */
1054 { $$ = newANONHASH(NULL); }
1055 | ANONSUB startanonsub proto subattrlist block %prec '('
1056 { SvREFCNT_inc_simple_void(PL_compcv);
1057 $$ = newANONATTRSUB($2, $3, $4, $5); }
1058 | ANONSUB startanonsub remember subsignature subattrlist '{' stmtseq '}' %prec '('
1059 {
1060 OP *body;
1061 if (parser->copline > (line_t)$6)
1062 parser->copline = (line_t)$6;
1063 body = block_end($3,
1064 op_append_list(OP_LINESEQ, $4, $7));
1065 SvREFCNT_inc_simple_void(PL_compcv);
1066 $$ = newANONATTRSUB($2, NULL, $5, body);
1067 }
1068
1069 ;
1070
1071/* Things called with "do" */
1072termdo : DO term %prec UNIOP /* do $filename */
1073 { $$ = dofile($2, $1);}
1074 | DO block %prec '(' /* do { code */
1075 { $$ = newUNOP(OP_NULL, OPf_SPECIAL, op_scope($2));}
1076 ;
1077
1078term : termbinop
1079 | termunop
1080 | anonymous
1081 | termdo
1082 | term '?' term ':' term
1083 { $$ = newCONDOP(0, $1, $3, $5); }
1084 | REFGEN term /* \$x, \@y, \%z */
1085 { $$ = newUNOP(OP_REFGEN, 0, $2); }
1086 | MY REFGEN term
1087 { $$ = newUNOP(OP_REFGEN, 0, localize($3,1)); }
1088 | myattrterm %prec UNIOP
1089 { $$ = $1; }
1090 | LOCAL term %prec UNIOP
1091 { $$ = localize($2,0); }
1092 | '(' expr ')'
1093 { $$ = sawparens($2); }
1094 | QWLIST
1095 { $$ = $1; }
1096 | '(' ')'
1097 { $$ = sawparens(newNULLLIST()); }
1098 | scalar %prec '('
1099 { $$ = $1; }
1100 | star %prec '('
1101 { $$ = $1; }
1102 | hsh %prec '('
1103 { $$ = $1; }
1104 | ary %prec '('
1105 { $$ = $1; }
1106 | arylen %prec '(' /* $#x, $#{ something } */
1107 { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));}
1108 | subscripted
1109 { $$ = $1; }
1110 | sliceme '[' expr ']' /* array slice */
1111 { $$ = op_prepend_elem(OP_ASLICE,
1112 newOP(OP_PUSHMARK, 0),
1113 newLISTOP(OP_ASLICE, 0,
1114 list($3),
1115 ref($1, OP_ASLICE)));
1116 if ($$ && $1)
1117 $$->op_private |=
1118 $1->op_private & OPpSLICEWARNING;
1119 }
1120 | kvslice '[' expr ']' /* array key/value slice */
1121 { $$ = op_prepend_elem(OP_KVASLICE,
1122 newOP(OP_PUSHMARK, 0),
1123 newLISTOP(OP_KVASLICE, 0,
1124 list($3),
1125 ref(oopsAV($1), OP_KVASLICE)));
1126 if ($$ && $1)
1127 $$->op_private |=
1128 $1->op_private & OPpSLICEWARNING;
1129 }
1130 | sliceme '{' expr ';' '}' /* @hash{@keys} */
1131 { $$ = op_prepend_elem(OP_HSLICE,
1132 newOP(OP_PUSHMARK, 0),
1133 newLISTOP(OP_HSLICE, 0,
1134 list($3),
1135 ref(oopsHV($1), OP_HSLICE)));
1136 if ($$ && $1)
1137 $$->op_private |=
1138 $1->op_private & OPpSLICEWARNING;
1139 }
1140 | kvslice '{' expr ';' '}' /* %hash{@keys} */
1141 { $$ = op_prepend_elem(OP_KVHSLICE,
1142 newOP(OP_PUSHMARK, 0),
1143 newLISTOP(OP_KVHSLICE, 0,
1144 list($3),
1145 ref($1, OP_KVHSLICE)));
1146 if ($$ && $1)
1147 $$->op_private |=
1148 $1->op_private & OPpSLICEWARNING;
1149 }
1150 | THING %prec '('
1151 { $$ = $1; }
1152 | amper /* &foo; */
1153 { $$ = newUNOP(OP_ENTERSUB, 0, scalar($1)); }
1154 | amper '(' ')' /* &foo() or foo() */
1155 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1));
1156 }
1157 | amper '(' expr ')' /* &foo(@args) or foo(@args) */
1158 {
1159 $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1160 op_append_elem(OP_LIST, $3, scalar($1)));
1161 }
1162 | NOAMP subname optlistexpr /* foo @args (no parens) */
1163 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1164 op_append_elem(OP_LIST, $3, scalar($2)));
1165 }
1166 | term ARROW '$' '*'
1167 { $$ = newSVREF($1); }
1168 | term ARROW '@' '*'
1169 { $$ = newAVREF($1); }
1170 | term ARROW '%' '*'
1171 { $$ = newHVREF($1); }
1172 | term ARROW '&' '*'
1173 { $$ = newUNOP(OP_ENTERSUB, 0,
1174 scalar(newCVREF($3,$1))); }
1175 | term ARROW '*' '*' %prec '('
1176 { $$ = newGVREF(0,$1); }
1177 | LOOPEX /* loop exiting command (goto, last, dump, etc) */
1178 { $$ = newOP($1, OPf_SPECIAL);
1179 PL_hints |= HINT_BLOCK_SCOPE; }
1180 | LOOPEX term
1181 { $$ = newLOOPEX($1,$2); }
1182 | NOTOP listexpr /* not $foo */
1183 { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
1184 | UNIOP /* Unary op, $_ implied */
1185 { $$ = newOP($1, 0); }
1186 | UNIOP block /* eval { foo }* */
1187 { $$ = newUNOP($1, 0, $2); }
1188 | UNIOP term /* Unary op */
1189 { $$ = newUNOP($1, 0, $2); }
1190 | REQUIRE /* require, $_ implied */
1191 { $$ = newOP(OP_REQUIRE, $1 ? OPf_SPECIAL : 0); }
1192 | REQUIRE term /* require Foo */
1193 { $$ = newUNOP(OP_REQUIRE, $1 ? OPf_SPECIAL : 0, $2); }
1194 | UNIOPSUB
1195 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); }
1196 | UNIOPSUB term /* Sub treated as unop */
1197 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1198 op_append_elem(OP_LIST, $2, scalar($1))); }
1199 | FUNC0 /* Nullary operator */
1200 { $$ = newOP($1, 0); }
1201 | FUNC0 '(' ')'
1202 { $$ = newOP($1, 0);}
1203 | FUNC0OP /* Same as above, but op created in toke.c */
1204 { $$ = $1; }
1205 | FUNC0OP '(' ')'
1206 { $$ = $1; }
1207 | FUNC0SUB /* Sub treated as nullop */
1208 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); }
1209 | FUNC1 '(' ')' /* not () */
1210 { $$ = ($1 == OP_NOT)
1211 ? newUNOP($1, 0, newSVOP(OP_CONST, 0, newSViv(0)))
1212 : newOP($1, OPf_SPECIAL); }
1213 | FUNC1 '(' expr ')' /* not($foo) */
1214 { $$ = newUNOP($1, 0, $3); }
1215 | PMFUNC /* m//, s///, qr//, tr/// */
1216 {
1217 if ( $1->op_type != OP_TRANS
1218 && $1->op_type != OP_TRANSR
1219 && (((PMOP*)$1)->op_pmflags & PMf_HAS_CV))
1220 {
1221 $<ival>$ = start_subparse(FALSE, CVf_ANON);
1222 SAVEFREESV(PL_compcv);
1223 } else
1224 $<ival>$ = 0;
1225 }
1226 '(' listexpr optrepl ')'
1227 { $$ = pmruntime($1, $4, $5, 1, $<ival>2); }
1228 | BAREWORD
1229 | listop
1230 | PLUGEXPR
1231 ;
1232
1233/* "my" declarations, with optional attributes */
1234myattrterm: MY myterm myattrlist
1235 { $$ = my_attrs($2,$3); }
1236 | MY myterm
1237 { $$ = localize($2,1); }
1238 | MY REFGEN myterm myattrlist
1239 { $$ = newUNOP(OP_REFGEN, 0, my_attrs($3,$4)); }
1240 ;
1241
1242/* Things that can be "my"'d */
1243myterm : '(' expr ')'
1244 { $$ = sawparens($2); }
1245 | '(' ')'
1246 { $$ = sawparens(newNULLLIST()); }
1247
1248 | scalar %prec '('
1249 { $$ = $1; }
1250 | hsh %prec '('
1251 { $$ = $1; }
1252 | ary %prec '('
1253 { $$ = $1; }
1254 ;
1255
1256/* Basic list expressions */
1257optlistexpr: /* NULL */ %prec PREC_LOW
1258 { $$ = NULL; }
1259 | listexpr %prec PREC_LOW
1260 { $$ = $1; }
1261 ;
1262
1263optexpr: /* NULL */
1264 { $$ = NULL; }
1265 | expr
1266 { $$ = $1; }
1267 ;
1268
1269optrepl: /* NULL */
1270 { $$ = NULL; }
1271 | '/' expr
1272 { $$ = $2; }
1273 ;
1274
1275/* A little bit of trickery to make "for my $foo (@bar)" actually be
1276 lexical */
1277my_scalar: scalar
1278 { parser->in_my = 0; $$ = my($1); }
1279 ;
1280
1281my_var : scalar
1282 | ary
1283 | hsh
1284 ;
1285
1286refgen_topic: my_var
1287 | amper
1288 ;
1289
1290my_refgen: MY REFGEN
1291 | REFGEN MY
1292 ;
1293
1294amper : '&' indirob
1295 { $$ = newCVREF($1,$2); }
1296 ;
1297
1298scalar : '$' indirob
1299 { $$ = newSVREF($2); }
1300 ;
1301
1302ary : '@' indirob
1303 { $$ = newAVREF($2);
1304 if ($$) $$->op_private |= $1;
1305 }
1306 ;
1307
1308hsh : '%' indirob
1309 { $$ = newHVREF($2);
1310 if ($$) $$->op_private |= $1;
1311 }
1312 ;
1313
1314arylen : DOLSHARP indirob
1315 { $$ = newAVREF($2); }
1316 | term ARROW DOLSHARP '*'
1317 { $$ = newAVREF($1); }
1318 ;
1319
1320star : '*' indirob
1321 { $$ = newGVREF(0,$2); }
1322 ;
1323
1324sliceme : ary
1325 | term ARROW '@'
1326 { $$ = newAVREF($1); }
1327 ;
1328
1329kvslice : hsh
1330 | term ARROW '%'
1331 { $$ = newHVREF($1); }
1332 ;
1333
1334gelem : star
1335 | term ARROW '*'
1336 { $$ = newGVREF(0,$1); }
1337 ;
1338
1339/* Indirect objects */
1340indirob : BAREWORD
1341 { $$ = scalar($1); }
1342 | scalar %prec PREC_LOW
1343 { $$ = scalar($1); }
1344 | block
1345 { $$ = op_scope($1); }
1346
1347 | PRIVATEREF
1348 { $$ = $1; }
1349 ;