3 * Copyright (c) 1991-2002, 2003, 2004, 2005, 2006 Larry Wall
4 * Copyright (c) 2007, 2008, 2009, 2010, 2011 by Larry Wall and others
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.
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.'
15 * [p.171 of _The Lord of the Rings_, I/x: "Strider"]
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.
23 * The main job 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.
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
32 /* Make the parser re-entrant. */
39 I32 ival; /* __DEFAULT__ (marker for regen_perly.pl;
40 must always be 1st union member) */
46 %token <ival> GRAMPROG GRAMEXPR GRAMBLOCK GRAMBARESTMT GRAMFULLSTMT GRAMSTMTSEQ GRAMSUBSIGNATURE
48 %token <ival> PERLY_AMPERSAND
49 %token <ival> PERLY_BRACE_OPEN
50 %token <ival> PERLY_BRACE_CLOSE
51 %token <ival> PERLY_BRACKET_OPEN
52 %token <ival> PERLY_BRACKET_CLOSE
53 %token <ival> PERLY_COMMA
54 %token <ival> PERLY_DOLLAR
55 %token <ival> PERLY_DOT
56 %token <ival> PERLY_EQUAL_SIGN
57 %token <ival> PERLY_MINUS
58 %token <ival> PERLY_PERCENT_SIGN
59 %token <ival> PERLY_PLUS
60 %token <ival> PERLY_SEMICOLON
61 %token <ival> PERLY_SLASH
62 %token <ival> PERLY_SNAIL
63 %token <ival> PERLY_STAR
65 %token <opval> BAREWORD METHOD FUNCMETH THING PMFUNC PRIVATEREF QWLIST
66 %token <opval> FUNC0OP FUNC0SUB UNIOPSUB LSTOPSUB
67 %token <opval> PLUGEXPR PLUGSTMT
69 %token <ival> FORMAT SUB SIGSUB ANONSUB ANON_SIGSUB PACKAGE USE
70 %token <ival> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
71 %token <ival> GIVEN WHEN DEFAULT
72 %token <ival> LOOPEX DOTDOT YADAYADA
73 %token <ival> FUNC0 FUNC1 FUNC UNIOP LSTOP
74 %token <ival> MULOP ADDOP
75 %token <ival> DOLSHARP DO HASHBRACK NOAMP
76 %token <ival> LOCAL MY REQUIRE
77 %token <ival> COLONATTR FORMLBRACK FORMRBRACK
78 %token <ival> SUBLEXSTART SUBLEXEND
80 %type <ival> grammar remember mremember
81 %type <ival> startsub startanonsub startformsub
85 %type <opval> stmtseq fullstmt labfullstmt barestmt block mblock else
86 %type <opval> expr term subscripted scalar ary hsh arylen star amper sideff
87 %type <opval> condition
88 %type <opval> sliceme kvslice gelem
89 %type <opval> listexpr nexpr texpr iexpr mexpr mnexpr
90 %type <opval> optlistexpr optexpr optrepl indirob listop method
91 %type <opval> formname subname proto cont my_scalar my_var
92 %type <opval> refgen_topic formblock
93 %type <opval> subattrlist myattrlist myattrterm myterm
94 %type <opval> termbinop termunop anonymous termdo
95 %type <opval> termrelop relopchain termeqop eqopchain
96 %type <ival> sigslurpsigil
97 %type <opval> sigvarname sigdefault sigscalarelem sigslurpelem
98 %type <opval> sigelem siglist siglistornull subsigguts subsignature optsubsignature
99 %type <opval> subbody optsubbody sigsubbody optsigsubbody
100 %type <opval> formstmtseq formline formarg
102 %nonassoc <ival> PREC_LOW
105 %left <ival> OROP DOROP
108 %nonassoc LSTOP LSTOPSUB
110 %right <ival> ASSIGNOP
111 %right <ival> PERLY_QUESTION_MARK PERLY_COLON
113 %left <ival> OROR DORDOR
116 %left <ival> BITANDOP
117 %left <ival> CHEQOP NCEQOP
118 %left <ival> CHRELOP NCRELOP
119 %nonassoc UNIOP UNIOPSUB
125 %right <ival> PERLY_EXCLAMATION_MARK PERLY_TILDE UMINUS REFGEN
127 %nonassoc <ival> PREINC PREDEC POSTINC POSTDEC POSTJOIN
129 %nonassoc <ival> PERLY_PAREN_CLOSE
130 %left <ival> PERLY_PAREN_OPEN
131 %left PERLY_BRACKET_OPEN PERLY_BRACE_OPEN
135 /* Top-level choice of what kind of thing yyparse was called to parse */
138 parser->expect = XSTATE;
143 newPROG(block_end($remember,$stmtseq));
144 PL_compiling.cop_seq = 0;
149 parser->expect = XTERM;
154 PL_eval_root = $optexpr;
159 parser->expect = XBLOCK;
164 PL_pad_reset_pending = TRUE;
165 PL_eval_root = $block;
168 parser->yychar = yytoken = YYEOF;
172 parser->expect = XSTATE;
177 PL_pad_reset_pending = TRUE;
178 PL_eval_root = $barestmt;
181 parser->yychar = yytoken = YYEOF;
185 parser->expect = XSTATE;
190 PL_pad_reset_pending = TRUE;
191 PL_eval_root = $fullstmt;
194 parser->yychar = yytoken = YYEOF;
198 parser->expect = XSTATE;
203 PL_eval_root = $stmtseq;
208 parser->expect = XSTATE;
213 PL_eval_root = $subsigguts;
218 /* An ordinary block */
219 block : PERLY_BRACE_OPEN remember stmtseq PERLY_BRACE_CLOSE
220 { if (parser->copline > (line_t)$PERLY_BRACE_OPEN)
221 parser->copline = (line_t)$PERLY_BRACE_OPEN;
222 $$ = block_end($remember, $stmtseq);
227 formblock: PERLY_EQUAL_SIGN remember PERLY_SEMICOLON FORMRBRACK formstmtseq PERLY_SEMICOLON PERLY_DOT
228 { if (parser->copline > (line_t)$PERLY_EQUAL_SIGN)
229 parser->copline = (line_t)$PERLY_EQUAL_SIGN;
230 $$ = block_end($remember, $formstmtseq);
234 remember: /* NULL */ /* start a full lexical scope */
235 { $$ = block_start(TRUE);
236 parser->parsed_sub = 0; }
239 mblock : PERLY_BRACE_OPEN mremember stmtseq PERLY_BRACE_CLOSE
240 { if (parser->copline > (line_t)$PERLY_BRACE_OPEN)
241 parser->copline = (line_t)$PERLY_BRACE_OPEN;
242 $$ = block_end($mremember, $stmtseq);
246 mremember: /* NULL */ /* start a partial lexical scope */
247 { $$ = block_start(FALSE);
248 parser->parsed_sub = 0; }
251 /* A sequence of statements in the program */
254 | stmtseq[list] fullstmt
255 { $$ = op_append_list(OP_LINESEQ, $list, $fullstmt);
256 PL_pad_reset_pending = TRUE;
257 if ($list && $fullstmt)
258 PL_hints |= HINT_BLOCK_SCOPE;
262 /* A sequence of format lines */
263 formstmtseq: /* NULL */
265 | formstmtseq[list] formline
266 { $$ = op_append_list(OP_LINESEQ, $list, $formline);
267 PL_pad_reset_pending = TRUE;
268 if ($list && $formline)
269 PL_hints |= HINT_BLOCK_SCOPE;
273 /* A statement in the program, including optional labels */
276 $$ = $barestmt ? newSTATEOP(0, NULL, $barestmt) : NULL;
279 { $$ = $labfullstmt; }
282 labfullstmt: LABEL barestmt
284 SV *label = cSVOPx_sv($LABEL);
285 $$ = newSTATEOP(SvFLAGS(label) & SVf_UTF8,
286 savepv(SvPVX_const(label)), $barestmt);
289 | LABEL labfullstmt[list]
291 SV *label = cSVOPx_sv($LABEL);
292 $$ = newSTATEOP(SvFLAGS(label) & SVf_UTF8,
293 savepv(SvPVX_const(label)), $list);
298 /* A bare statement, lacking label and other aspects of state op */
301 | FORMAT startformsub formname formblock
303 CV *fmtcv = PL_compcv;
304 newFORM($startformsub, $formname, $formblock);
306 if (CvOUTSIDE(fmtcv) && !CvEVAL(CvOUTSIDE(fmtcv))) {
307 pad_add_weakref(fmtcv);
309 parser->parsed_sub = 1;
311 | SUB subname startsub
312 /* sub declaration or definition not within scope
313 of 'use feature "signatures"'*/
315 init_named_cv(PL_compcv, $subname);
317 parser->in_my_stash = NULL;
319 proto subattrlist optsubbody
321 SvREFCNT_inc_simple_void(PL_compcv);
322 $subname->op_type == OP_CONST
323 ? newATTRSUB($startsub, $subname, $proto, $subattrlist, $optsubbody)
324 : newMYSUB($startsub, $subname, $proto, $subattrlist, $optsubbody)
328 parser->parsed_sub = 1;
330 | SIGSUB subname startsub
331 /* sub declaration or definition under 'use feature
332 * "signatures"'. (Note that a signature isn't
333 * allowed in a declaration)
336 init_named_cv(PL_compcv, $subname);
338 parser->in_my_stash = NULL;
340 subattrlist optsigsubbody
342 SvREFCNT_inc_simple_void(PL_compcv);
343 $subname->op_type == OP_CONST
344 ? newATTRSUB($startsub, $subname, NULL, $subattrlist, $optsigsubbody)
345 : newMYSUB( $startsub, $subname, NULL, $subattrlist, $optsigsubbody)
349 parser->parsed_sub = 1;
351 | PACKAGE BAREWORD[version] BAREWORD[package] PERLY_SEMICOLON
355 package_version($version);
359 { CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ }
360 BAREWORD[version] BAREWORD[module] optlistexpr PERLY_SEMICOLON
362 SvREFCNT_inc_simple_void(PL_compcv);
363 utilize($USE, $startsub, $version, $module, $optlistexpr);
364 parser->parsed_sub = 1;
367 | IF PERLY_PAREN_OPEN remember mexpr PERLY_PAREN_CLOSE mblock else
369 $$ = block_end($remember,
370 newCONDOP(0, $mexpr, op_scope($mblock), $else));
371 parser->copline = (line_t)$IF;
373 | UNLESS PERLY_PAREN_OPEN remember mexpr PERLY_PAREN_CLOSE mblock else
375 $$ = block_end($remember,
376 newCONDOP(0, $mexpr, $else, op_scope($mblock)));
377 parser->copline = (line_t)$UNLESS;
379 | GIVEN PERLY_PAREN_OPEN remember mexpr PERLY_PAREN_CLOSE mblock
381 $$ = block_end($remember, newGIVENOP($mexpr, op_scope($mblock), 0));
382 parser->copline = (line_t)$GIVEN;
384 | WHEN PERLY_PAREN_OPEN remember mexpr PERLY_PAREN_CLOSE mblock
385 { $$ = block_end($remember, newWHENOP($mexpr, op_scope($mblock))); }
387 { $$ = newWHENOP(0, op_scope($block)); }
388 | WHILE PERLY_PAREN_OPEN remember texpr PERLY_PAREN_CLOSE mintro mblock cont
390 $$ = block_end($remember,
391 newWHILEOP(0, 1, NULL,
392 $texpr, $mblock, $cont, $mintro));
393 parser->copline = (line_t)$WHILE;
395 | UNTIL PERLY_PAREN_OPEN remember iexpr PERLY_PAREN_CLOSE mintro mblock cont
397 $$ = block_end($remember,
398 newWHILEOP(0, 1, NULL,
399 $iexpr, $mblock, $cont, $mintro));
400 parser->copline = (line_t)$UNTIL;
402 | FOR PERLY_PAREN_OPEN remember mnexpr[init_mnexpr] PERLY_SEMICOLON
403 { parser->expect = XTERM; }
404 texpr PERLY_SEMICOLON
405 { parser->expect = XTERM; }
406 mintro mnexpr[iterate_mnexpr] PERLY_PAREN_CLOSE
409 OP *initop = $init_mnexpr;
410 OP *forop = newWHILEOP(0, 1, NULL,
411 scalar($texpr), $mblock, $iterate_mnexpr, $mintro);
413 forop = op_prepend_elem(OP_LINESEQ, initop,
414 op_append_elem(OP_LINESEQ,
415 newOP(OP_UNSTACK, OPf_SPECIAL),
418 PL_hints |= HINT_BLOCK_SCOPE;
419 $$ = block_end($remember, forop);
420 parser->copline = (line_t)$FOR;
422 | FOR MY remember my_scalar PERLY_PAREN_OPEN mexpr PERLY_PAREN_CLOSE mblock cont
424 $$ = block_end($remember, newFOROP(0, $my_scalar, $mexpr, $mblock, $cont));
425 parser->copline = (line_t)$FOR;
427 | FOR scalar PERLY_PAREN_OPEN remember mexpr PERLY_PAREN_CLOSE mblock cont
429 $$ = block_end($remember, newFOROP(0,
430 op_lvalue($scalar, OP_ENTERLOOP), $mexpr, $mblock, $cont));
431 parser->copline = (line_t)$FOR;
433 | FOR my_refgen remember my_var
434 { parser->in_my = 0; $<opval>$ = my($my_var); }[variable]
435 PERLY_PAREN_OPEN mexpr PERLY_PAREN_CLOSE mblock cont
441 newUNOP(OP_REFGEN, 0,
444 $mexpr, $mblock, $cont)
446 parser->copline = (line_t)$FOR;
448 | FOR REFGEN refgen_topic PERLY_PAREN_OPEN remember mexpr PERLY_PAREN_CLOSE mblock cont
450 $$ = block_end($remember, newFOROP(
451 0, op_lvalue(newUNOP(OP_REFGEN, 0,
453 OP_ENTERLOOP), $mexpr, $mblock, $cont));
454 parser->copline = (line_t)$FOR;
456 | FOR PERLY_PAREN_OPEN remember mexpr PERLY_PAREN_CLOSE mblock cont
458 $$ = block_end($remember,
459 newFOROP(0, NULL, $mexpr, $mblock, $cont));
460 parser->copline = (line_t)$FOR;
464 /* a block is a loop that happens once */
465 $$ = newWHILEOP(0, 1, NULL,
466 NULL, $block, $cont, 0);
468 | PACKAGE BAREWORD[version] BAREWORD[package] PERLY_BRACE_OPEN remember
472 package_version($version);
475 stmtseq PERLY_BRACE_CLOSE
477 /* a block is a loop that happens once */
478 $$ = newWHILEOP(0, 1, NULL,
479 NULL, block_end($remember, $stmtseq), NULL, 0);
480 if (parser->copline > (line_t)$PERLY_BRACE_OPEN)
481 parser->copline = (line_t)$PERLY_BRACE_OPEN;
483 | sideff PERLY_SEMICOLON
487 | YADAYADA PERLY_SEMICOLON
489 $$ = newLISTOP(OP_DIE, 0, newOP(OP_PUSHMARK, 0),
490 newSVOP(OP_CONST, 0, newSVpvs("Unimplemented")));
495 parser->copline = NOLINE;
500 formline: THING formarg
504 list = op_append_elem(OP_LIST, $THING, term);
509 if (parser->copline == NOLINE)
510 parser->copline = CopLINE(PL_curcop)-1;
511 else parser->copline--;
512 $$ = newSTATEOP(0, NULL,
513 op_convert_list(OP_FORMLINE, 0, list));
519 | FORMLBRACK stmtseq FORMRBRACK
520 { $$ = op_unscope($stmtseq); }
526 /* An expression which may have a side-effect */
531 | expr[body] IF condition
532 { $$ = newLOGOP(OP_AND, 0, $condition, $body); }
533 | expr[body] UNLESS condition
534 { $$ = newLOGOP(OP_OR, 0, $condition, $body); }
535 | expr[body] WHILE condition
536 { $$ = newLOOPOP(OPf_PARENS, 1, scalar($condition), $body); }
537 | expr[body] UNTIL iexpr
538 { $$ = newLOOPOP(OPf_PARENS, 1, $iexpr, $body); }
539 | expr[body] FOR condition
540 { $$ = newFOROP(0, NULL, $condition, $body, NULL);
541 parser->copline = (line_t)$FOR; }
542 | expr[body] WHEN condition
543 { $$ = newWHENOP($condition, op_scope($body)); }
546 /* else and elsif blocks */
551 ($mblock)->op_flags |= OPf_PARENS;
552 $$ = op_scope($mblock);
554 | ELSIF PERLY_PAREN_OPEN mexpr PERLY_PAREN_CLOSE mblock else[else.recurse]
555 { parser->copline = (line_t)$ELSIF;
557 newSTATEOP(OPf_SPECIAL,NULL,$mexpr),
558 op_scope($mblock), $[else.recurse]);
559 PL_hints |= HINT_BLOCK_SCOPE;
563 /* Continue blocks */
567 { $$ = op_scope($block); }
570 /* determine whether there are any new my declarations */
572 { $$ = (PL_min_intro_pending &&
573 PL_max_intro_pending >= PL_min_intro_pending);
576 /* Normal expression */
582 /* Boolean expression */
583 texpr : /* NULL means true */
585 (void)scan_num("1", &tmplval);
586 $$ = tmplval.opval; }
590 /* Inverted boolean expression */
592 { $$ = invert(scalar($expr)); }
595 /* Expression with its own lexical scope */
597 { $$ = $expr; intro_my(); }
601 { $$ = $nexpr; intro_my(); }
604 formname: BAREWORD { $$ = $BAREWORD; }
605 | /* NULL */ { $$ = NULL; }
608 startsub: /* NULL */ /* start a regular subroutine scope */
609 { $$ = start_subparse(FALSE, 0);
610 SAVEFREESV(PL_compcv); }
614 startanonsub: /* NULL */ /* start an anonymous subroutine scope */
615 { $$ = start_subparse(FALSE, CVf_ANON);
616 SAVEFREESV(PL_compcv); }
619 startformsub: /* NULL */ /* start a format subroutine scope */
620 { $$ = start_subparse(TRUE, 0);
621 SAVEFREESV(PL_compcv); }
624 /* Name of a subroutine - must be a bareword, could be special */
629 /* Subroutine prototype */
635 /* Optional list of subroutine attributes */
636 subattrlist: /* NULL */
644 /* List of attributes for a "my" variable declaration */
645 myattrlist: COLONATTR THING
653 /* --------------------------------------
654 * subroutine signature parsing
657 /* the '' or 'foo' part of a '$' or '@foo' etc signature variable */
658 sigvarname: /* NULL */
659 { parser->in_my = 0; $$ = NULL; }
661 { parser->in_my = 0; $$ = $PRIVATEREF; }
670 /* @, %, @foo, %foo */
671 sigslurpelem: sigslurpsigil sigvarname sigdefault/* def only to catch errors */
673 I32 sigil = $sigslurpsigil;
674 OP *var = $sigvarname;
675 OP *defexpr = $sigdefault;
677 if (parser->sig_slurpy)
678 yyerror("Multiple slurpy parameters not allowed");
679 parser->sig_slurpy = (char)sigil;
682 yyerror("A slurpy parameter may not have "
685 $$ = var ? newSTATEOP(0, NULL, var) : NULL;
689 /* default part of sub signature scalar element: i.e. '= default_expr' */
690 sigdefault: /* NULL */
693 { $$ = newOP(OP_NULL, 0); }
698 /* subroutine signature scalar element: e.g. '$x', '$=', '$x = $default' */
700 PERLY_DOLLAR sigvarname sigdefault
702 OP *var = $sigvarname;
703 OP *defexpr = $sigdefault;
705 if (parser->sig_slurpy)
706 yyerror("Slurpy parameter not last");
711 parser->sig_optelems++;
713 if ( defexpr->op_type == OP_NULL
714 && !(defexpr->op_flags & OPf_KIDS))
716 /* handle '$=' special case */
718 yyerror("Optional parameter "
719 "lacks default expression");
723 /* a normal '=default' expression */
724 OP *defop = (OP*)alloc_LOGOP(OP_ARGDEFELEM,
727 /* re-purpose op_targ to hold @_ index */
729 (PADOFFSET)(parser->sig_elems - 1);
732 var->op_flags |= OPf_STACKED;
733 (void)op_sibling_splice(var,
738 var = newUNOP(OP_NULL, 0, defop);
741 /* NB: normally the first child of a
742 * logop is executed before the logop,
743 * and it pushes a boolean result
744 * ready for the logop. For ARGDEFELEM,
745 * the op itself does the boolean
746 * calculation, so set the first op to
749 var->op_next = defop;
750 defexpr->op_next = var;
754 if (parser->sig_optelems)
755 yyerror("Mandatory parameter "
756 "follows optional parameter");
759 $$ = var ? newSTATEOP(0, NULL, var) : NULL;
764 /* subroutine signature element: e.g. '$x = $default' or '%h' */
765 sigelem: sigscalarelem
766 { parser->in_my = KEY_sigvar; $$ = $sigscalarelem; }
768 { parser->in_my = KEY_sigvar; $$ = $sigslurpelem; }
771 /* list of subroutine signature elements */
773 siglist[list] PERLY_COMMA
775 | siglist[list] PERLY_COMMA sigelem[element]
777 $$ = op_append_list(OP_LINESEQ, $list, $element);
779 | sigelem[element] %prec PREC_LOW
784 siglistornull: /* NULL */
789 /* optional subroutine signature */
790 optsubsignature: /* NULL */
793 { $$ = $subsignature; }
795 /* Subroutine signature */
796 subsignature: PERLY_PAREN_OPEN subsigguts PERLY_PAREN_CLOSE
797 { $$ = $subsigguts; }
802 SAVEIV(parser->sig_elems);
803 SAVEIV(parser->sig_optelems);
804 SAVEI8(parser->sig_slurpy);
805 parser->sig_elems = 0;
806 parser->sig_optelems = 0;
807 parser->sig_slurpy = 0;
808 parser->in_my = KEY_sigvar;
812 OP *sigops = $siglistornull;
813 struct op_argcheck_aux *aux;
816 if (!FEATURE_SIGNATURES_IS_ENABLED)
817 Perl_croak(aTHX_ "Experimental "
818 "subroutine signatures not enabled");
820 /* We shouldn't get here otherwise */
821 Perl_ck_warner_d(aTHX_
822 packWARN(WARN_EXPERIMENTAL__SIGNATURES),
823 "The signatures feature is experimental");
825 aux = (struct op_argcheck_aux*)
826 PerlMemShared_malloc(
827 sizeof(struct op_argcheck_aux));
828 aux->params = parser->sig_elems;
829 aux->opt_params = parser->sig_optelems;
830 aux->slurpy = parser->sig_slurpy;
831 check = newUNOP_AUX(OP_ARGCHECK, 0, NULL,
832 (UNOP_AUX_item *)aux);
833 sigops = op_prepend_elem(OP_LINESEQ, check, sigops);
834 sigops = op_prepend_elem(OP_LINESEQ,
835 newSTATEOP(0, NULL, NULL),
837 /* a nextstate at the end handles context
838 * correctly for an empty sub body */
839 sigops = op_append_elem(OP_LINESEQ,
841 newSTATEOP(0, NULL, NULL));
842 /* wrap the list of arg ops in a NULL aux op.
843 This serves two purposes. First, it makes
844 the arg list a separate subtree from the
845 body of the sub, and secondly the null op
846 may in future be upgraded to an OP_SIGNATURE
847 when implemented. For now leave it as
849 $$ = newUNOP_AUX(OP_ARGCHECK, 0, sigops, NULL);
853 /* tell the toker that attrributes can follow
854 * this sig, but only so that the toker
855 * can skip through any (illegal) trailing
856 * attribute text then give a useful error
857 * message about "attributes before sig",
858 * rather than falling over ina mess at
859 * unrecognised syntax.
861 parser->expect = XATTRBLOCK;
862 parser->sig_seen = TRUE;
867 /* Optional subroutine body (for named subroutine declaration) */
868 optsubbody: subbody { $$ = $subbody; }
869 | PERLY_SEMICOLON { $$ = NULL; }
873 /* Subroutine body (without signature) */
874 subbody: remember PERLY_BRACE_OPEN stmtseq PERLY_BRACE_CLOSE
876 if (parser->copline > (line_t)$PERLY_BRACE_OPEN)
877 parser->copline = (line_t)$PERLY_BRACE_OPEN;
878 $$ = block_end($remember, $stmtseq);
883 /* optional [ Subroutine body with optional signature ] (for named
884 * subroutine declaration) */
885 optsigsubbody: sigsubbody { $$ = $sigsubbody; }
886 | PERLY_SEMICOLON { $$ = NULL; }
888 /* Subroutine body with optional signature */
889 sigsubbody: remember optsubsignature PERLY_BRACE_OPEN stmtseq PERLY_BRACE_CLOSE
891 if (parser->copline > (line_t)$PERLY_BRACE_OPEN)
892 parser->copline = (line_t)$PERLY_BRACE_OPEN;
893 $$ = block_end($remember,
894 op_append_list(OP_LINESEQ, $optsubsignature, $stmtseq));
899 /* Ordinary expressions; logical combinations */
900 expr : expr[lhs] ANDOP expr[rhs]
901 { $$ = newLOGOP(OP_AND, 0, $lhs, $rhs); }
902 | expr[lhs] OROP[operator] expr[rhs]
903 { $$ = newLOGOP($operator, 0, $lhs, $rhs); }
904 | expr[lhs] DOROP expr[rhs]
905 { $$ = newLOGOP(OP_DOR, 0, $lhs, $rhs); }
906 | listexpr %prec PREC_LOW
909 /* Expressions are a list of terms joined by commas */
910 listexpr: listexpr[list] PERLY_COMMA
912 | listexpr[list] PERLY_COMMA term
915 $$ = op_append_elem(OP_LIST, $list, term);
917 | term %prec PREC_LOW
921 listop : LSTOP indirob listexpr /* map {...} @args or print $fh @args */
922 { $$ = op_convert_list($LSTOP, OPf_STACKED,
923 op_prepend_elem(OP_LIST, newGVREF($LSTOP,$indirob), $listexpr) );
925 | FUNC PERLY_PAREN_OPEN indirob expr PERLY_PAREN_CLOSE /* print ($fh @args */
926 { $$ = op_convert_list($FUNC, OPf_STACKED,
927 op_prepend_elem(OP_LIST, newGVREF($FUNC,$indirob), $expr) );
929 | term ARROW method PERLY_PAREN_OPEN optexpr PERLY_PAREN_CLOSE /* $foo->bar(list) */
930 { $$ = op_convert_list(OP_ENTERSUB, OPf_STACKED,
931 op_append_elem(OP_LIST,
932 op_prepend_elem(OP_LIST, scalar($term), $optexpr),
933 newMETHOP(OP_METHOD, 0, $method)));
935 | term ARROW method /* $foo->bar */
936 { $$ = op_convert_list(OP_ENTERSUB, OPf_STACKED,
937 op_append_elem(OP_LIST, scalar($term),
938 newMETHOP(OP_METHOD, 0, $method)));
940 | METHOD indirob optlistexpr /* new Class @args */
941 { $$ = op_convert_list(OP_ENTERSUB, OPf_STACKED,
942 op_append_elem(OP_LIST,
943 op_prepend_elem(OP_LIST, $indirob, $optlistexpr),
944 newMETHOP(OP_METHOD, 0, $METHOD)));
946 | FUNCMETH indirob PERLY_PAREN_OPEN optexpr PERLY_PAREN_CLOSE /* method $object (@args) */
947 { $$ = op_convert_list(OP_ENTERSUB, OPf_STACKED,
948 op_append_elem(OP_LIST,
949 op_prepend_elem(OP_LIST, $indirob, $optexpr),
950 newMETHOP(OP_METHOD, 0, $FUNCMETH)));
952 | LSTOP optlistexpr /* print @args */
953 { $$ = op_convert_list($LSTOP, 0, $optlistexpr); }
954 | FUNC PERLY_PAREN_OPEN optexpr PERLY_PAREN_CLOSE /* print (@args) */
955 { $$ = op_convert_list($FUNC, 0, $optexpr); }
956 | FUNC SUBLEXSTART optexpr SUBLEXEND /* uc($arg) from "\U..." */
957 { $$ = op_convert_list($FUNC, 0, $optexpr); }
958 | LSTOPSUB startanonsub block /* sub f(&@); f { foo } ... */
959 { SvREFCNT_inc_simple_void(PL_compcv);
960 $<opval>$ = newANONATTRSUB($startanonsub, 0, NULL, $block); }[anonattrsub]
961 optlistexpr %prec LSTOP /* ... @bar */
962 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
963 op_append_elem(OP_LIST,
964 op_prepend_elem(OP_LIST, $<opval>anonattrsub, $optlistexpr), $LSTOPSUB));
968 /* Names of methods. May use $object->$methodname */
973 /* Some kind of subscripted expression */
974 subscripted: gelem PERLY_BRACE_OPEN expr PERLY_SEMICOLON PERLY_BRACE_CLOSE /* *main::{something} */
975 /* In this and all the hash accessors, PERLY_SEMICOLON is
976 * provided by the tokeniser */
977 { $$ = newBINOP(OP_GELEM, 0, $gelem, scalar($expr)); }
978 | scalar[array] PERLY_BRACKET_OPEN expr PERLY_BRACKET_CLOSE /* $array[$element] */
979 { $$ = newBINOP(OP_AELEM, 0, oopsAV($array), scalar($expr));
981 | term[array_reference] ARROW PERLY_BRACKET_OPEN expr PERLY_BRACKET_CLOSE /* somearef->[$element] */
982 { $$ = newBINOP(OP_AELEM, 0,
983 ref(newAVREF($array_reference),OP_RV2AV),
986 | subscripted[array_reference] PERLY_BRACKET_OPEN expr PERLY_BRACKET_CLOSE /* $foo->[$bar]->[$baz] */
987 { $$ = newBINOP(OP_AELEM, 0,
988 ref(newAVREF($array_reference),OP_RV2AV),
991 | scalar[hash] PERLY_BRACE_OPEN expr PERLY_SEMICOLON PERLY_BRACE_CLOSE /* $foo{bar();} */
992 { $$ = newBINOP(OP_HELEM, 0, oopsHV($hash), jmaybe($expr));
994 | term[hash_reference] ARROW PERLY_BRACE_OPEN expr PERLY_SEMICOLON PERLY_BRACE_CLOSE /* somehref->{bar();} */
995 { $$ = newBINOP(OP_HELEM, 0,
996 ref(newHVREF($hash_reference),OP_RV2HV),
998 | subscripted[hash_reference] PERLY_BRACE_OPEN expr PERLY_SEMICOLON PERLY_BRACE_CLOSE /* $foo->[bar]->{baz;} */
999 { $$ = newBINOP(OP_HELEM, 0,
1000 ref(newHVREF($hash_reference),OP_RV2HV),
1002 | term[code_reference] ARROW PERLY_PAREN_OPEN PERLY_PAREN_CLOSE /* $subref->() */
1003 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1004 newCVREF(0, scalar($code_reference)));
1005 if (parser->expect == XBLOCK)
1006 parser->expect = XOPERATOR;
1008 | term[code_reference] ARROW PERLY_PAREN_OPEN expr PERLY_PAREN_CLOSE /* $subref->(@args) */
1009 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1010 op_append_elem(OP_LIST, $expr,
1011 newCVREF(0, scalar($code_reference))));
1012 if (parser->expect == XBLOCK)
1013 parser->expect = XOPERATOR;
1016 | subscripted[code_reference] PERLY_PAREN_OPEN expr PERLY_PAREN_CLOSE /* $foo->{bar}->(@args) */
1017 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1018 op_append_elem(OP_LIST, $expr,
1019 newCVREF(0, scalar($code_reference))));
1020 if (parser->expect == XBLOCK)
1021 parser->expect = XOPERATOR;
1023 | subscripted[code_reference] PERLY_PAREN_OPEN PERLY_PAREN_CLOSE /* $foo->{bar}->() */
1024 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1025 newCVREF(0, scalar($code_reference)));
1026 if (parser->expect == XBLOCK)
1027 parser->expect = XOPERATOR;
1029 | PERLY_PAREN_OPEN expr[list] PERLY_PAREN_CLOSE PERLY_BRACKET_OPEN expr[slice] PERLY_BRACKET_CLOSE /* list slice */
1030 { $$ = newSLICEOP(0, $slice, $list); }
1031 | QWLIST PERLY_BRACKET_OPEN expr PERLY_BRACKET_CLOSE /* list literal slice */
1032 { $$ = newSLICEOP(0, $expr, $QWLIST); }
1033 | PERLY_PAREN_OPEN PERLY_PAREN_CLOSE PERLY_BRACKET_OPEN expr PERLY_BRACKET_CLOSE /* empty list slice! */
1034 { $$ = newSLICEOP(0, $expr, NULL); }
1037 /* Binary operators between terms */
1038 termbinop: term[lhs] ASSIGNOP term[rhs] /* $x = $y, $x += $y */
1039 { $$ = newASSIGNOP(OPf_STACKED, $lhs, $ASSIGNOP, $rhs); }
1040 | term[lhs] POWOP term[rhs] /* $x ** $y */
1041 { $$ = newBINOP($POWOP, 0, scalar($lhs), scalar($rhs)); }
1042 | term[lhs] MULOP term[rhs] /* $x * $y, $x x $y */
1043 { if ($MULOP != OP_REPEAT)
1045 $$ = newBINOP($MULOP, 0, $lhs, scalar($rhs));
1047 | term[lhs] ADDOP term[rhs] /* $x + $y */
1048 { $$ = newBINOP($ADDOP, 0, scalar($lhs), scalar($rhs)); }
1049 | term[lhs] SHIFTOP term[rhs] /* $x >> $y, $x << $y */
1050 { $$ = newBINOP($SHIFTOP, 0, scalar($lhs), scalar($rhs)); }
1051 | termrelop %prec PREC_LOW /* $x > $y, etc. */
1052 { $$ = $termrelop; }
1053 | termeqop %prec PREC_LOW /* $x == $y, $x cmp $y */
1055 | term[lhs] BITANDOP term[rhs] /* $x & $y */
1056 { $$ = newBINOP($BITANDOP, 0, scalar($lhs), scalar($rhs)); }
1057 | term[lhs] BITOROP term[rhs] /* $x | $y */
1058 { $$ = newBINOP($BITOROP, 0, scalar($lhs), scalar($rhs)); }
1059 | term[lhs] DOTDOT term[rhs] /* $x..$y, $x...$y */
1060 { $$ = newRANGE($DOTDOT, scalar($lhs), scalar($rhs)); }
1061 | term[lhs] ANDAND term[rhs] /* $x && $y */
1062 { $$ = newLOGOP(OP_AND, 0, $lhs, $rhs); }
1063 | term[lhs] OROR term[rhs] /* $x || $y */
1064 { $$ = newLOGOP(OP_OR, 0, $lhs, $rhs); }
1065 | term[lhs] DORDOR term[rhs] /* $x // $y */
1066 { $$ = newLOGOP(OP_DOR, 0, $lhs, $rhs); }
1067 | term[lhs] MATCHOP term[rhs] /* $x =~ /$y/ */
1068 { $$ = bind_match($MATCHOP, $lhs, $rhs); }
1071 termrelop: relopchain %prec PREC_LOW
1072 { $$ = cmpchain_finish($relopchain); }
1073 | term[lhs] NCRELOP term[rhs]
1074 { $$ = newBINOP($NCRELOP, 0, scalar($lhs), scalar($rhs)); }
1076 { yyerror("syntax error"); YYERROR; }
1078 { yyerror("syntax error"); YYERROR; }
1081 relopchain: term[lhs] CHRELOP term[rhs]
1082 { $$ = cmpchain_start($CHRELOP, $lhs, $rhs); }
1083 | relopchain[lhs] CHRELOP term[rhs]
1084 { $$ = cmpchain_extend($CHRELOP, $lhs, $rhs); }
1087 termeqop: eqopchain %prec PREC_LOW
1088 { $$ = cmpchain_finish($eqopchain); }
1089 | term[lhs] NCEQOP term[rhs]
1090 { $$ = newBINOP($NCEQOP, 0, scalar($lhs), scalar($rhs)); }
1092 { yyerror("syntax error"); YYERROR; }
1094 { yyerror("syntax error"); YYERROR; }
1097 eqopchain: term[lhs] CHEQOP term[rhs]
1098 { $$ = cmpchain_start($CHEQOP, $lhs, $rhs); }
1099 | eqopchain[lhs] CHEQOP term[rhs]
1100 { $$ = cmpchain_extend($CHEQOP, $lhs, $rhs); }
1103 /* Unary operators and terms */
1104 termunop : PERLY_MINUS term %prec UMINUS /* -$x */
1105 { $$ = newUNOP(OP_NEGATE, 0, scalar($term)); }
1106 | PERLY_PLUS term %prec UMINUS /* +$x */
1109 | PERLY_EXCLAMATION_MARK term /* !$x */
1110 { $$ = newUNOP(OP_NOT, 0, scalar($term)); }
1111 | PERLY_TILDE term /* ~$x */
1112 { $$ = newUNOP($PERLY_TILDE, 0, scalar($term)); }
1113 | term POSTINC /* $x++ */
1114 { $$ = newUNOP(OP_POSTINC, 0,
1115 op_lvalue(scalar($term), OP_POSTINC)); }
1116 | term POSTDEC /* $x-- */
1117 { $$ = newUNOP(OP_POSTDEC, 0,
1118 op_lvalue(scalar($term), OP_POSTDEC));}
1119 | term POSTJOIN /* implicit join after interpolated ->@ */
1120 { $$ = op_convert_list(OP_JOIN, 0,
1130 | PREINC term /* ++$x */
1131 { $$ = newUNOP(OP_PREINC, 0,
1132 op_lvalue(scalar($term), OP_PREINC)); }
1133 | PREDEC term /* --$x */
1134 { $$ = newUNOP(OP_PREDEC, 0,
1135 op_lvalue(scalar($term), OP_PREDEC)); }
1139 /* Constructors for anonymous data */
1140 anonymous: PERLY_BRACKET_OPEN expr PERLY_BRACKET_CLOSE
1141 { $$ = newANONLIST($expr); }
1142 | PERLY_BRACKET_OPEN PERLY_BRACKET_CLOSE
1143 { $$ = newANONLIST(NULL);}
1144 | HASHBRACK expr PERLY_SEMICOLON PERLY_BRACE_CLOSE %prec PERLY_PAREN_OPEN /* { foo => "Bar" } */
1145 { $$ = newANONHASH($expr); }
1146 | HASHBRACK PERLY_SEMICOLON PERLY_BRACE_CLOSE %prec PERLY_PAREN_OPEN /* { } (PERLY_SEMICOLON by tokener) */
1147 { $$ = newANONHASH(NULL); }
1148 | ANONSUB startanonsub proto subattrlist subbody %prec PERLY_PAREN_OPEN
1149 { SvREFCNT_inc_simple_void(PL_compcv);
1150 $$ = newANONATTRSUB($startanonsub, $proto, $subattrlist, $subbody); }
1151 | ANON_SIGSUB startanonsub subattrlist sigsubbody %prec PERLY_PAREN_OPEN
1152 { SvREFCNT_inc_simple_void(PL_compcv);
1153 $$ = newANONATTRSUB($startanonsub, NULL, $subattrlist, $sigsubbody); }
1156 /* Things called with "do" */
1157 termdo : DO term %prec UNIOP /* do $filename */
1158 { $$ = dofile($term, $DO);}
1159 | DO block %prec PERLY_PAREN_OPEN /* do { code */
1160 { $$ = newUNOP(OP_NULL, OPf_SPECIAL, op_scope($block));}
1163 term[product] : termbinop
1167 | term[condition] PERLY_QUESTION_MARK term[then] PERLY_COLON term[else]
1168 { $$ = newCONDOP(0, $condition, $then, $else); }
1169 | REFGEN term[operand] /* \$x, \@y, \%z */
1170 { $$ = newUNOP(OP_REFGEN, 0, $operand); }
1171 | MY REFGEN term[operand]
1172 { $$ = newUNOP(OP_REFGEN, 0, localize($operand,1)); }
1173 | myattrterm %prec UNIOP
1174 { $$ = $myattrterm; }
1175 | LOCAL term[operand] %prec UNIOP
1176 { $$ = localize($operand,0); }
1177 | PERLY_PAREN_OPEN expr PERLY_PAREN_CLOSE
1178 { $$ = sawparens($expr); }
1181 | PERLY_PAREN_OPEN PERLY_PAREN_CLOSE
1182 { $$ = sawparens(newNULLLIST()); }
1183 | scalar %prec PERLY_PAREN_OPEN
1185 | star %prec PERLY_PAREN_OPEN
1187 | hsh %prec PERLY_PAREN_OPEN
1189 | ary %prec PERLY_PAREN_OPEN
1191 | arylen %prec PERLY_PAREN_OPEN /* $#x, $#{ something } */
1192 { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($arylen, OP_AV2ARYLEN));}
1194 { $$ = $subscripted; }
1195 | sliceme PERLY_BRACKET_OPEN expr PERLY_BRACKET_CLOSE /* array slice */
1196 { $$ = op_prepend_elem(OP_ASLICE,
1197 newOP(OP_PUSHMARK, 0),
1198 newLISTOP(OP_ASLICE, 0,
1200 ref($sliceme, OP_ASLICE)));
1203 $sliceme->op_private & OPpSLICEWARNING;
1205 | kvslice PERLY_BRACKET_OPEN expr PERLY_BRACKET_CLOSE /* array key/value slice */
1206 { $$ = op_prepend_elem(OP_KVASLICE,
1207 newOP(OP_PUSHMARK, 0),
1208 newLISTOP(OP_KVASLICE, 0,
1210 ref(oopsAV($kvslice), OP_KVASLICE)));
1213 $kvslice->op_private & OPpSLICEWARNING;
1215 | sliceme PERLY_BRACE_OPEN expr PERLY_SEMICOLON PERLY_BRACE_CLOSE /* @hash{@keys} */
1216 { $$ = op_prepend_elem(OP_HSLICE,
1217 newOP(OP_PUSHMARK, 0),
1218 newLISTOP(OP_HSLICE, 0,
1220 ref(oopsHV($sliceme), OP_HSLICE)));
1223 $sliceme->op_private & OPpSLICEWARNING;
1225 | kvslice PERLY_BRACE_OPEN expr PERLY_SEMICOLON PERLY_BRACE_CLOSE /* %hash{@keys} */
1226 { $$ = op_prepend_elem(OP_KVHSLICE,
1227 newOP(OP_PUSHMARK, 0),
1228 newLISTOP(OP_KVHSLICE, 0,
1230 ref($kvslice, OP_KVHSLICE)));
1233 $kvslice->op_private & OPpSLICEWARNING;
1235 | THING %prec PERLY_PAREN_OPEN
1238 { $$ = newUNOP(OP_ENTERSUB, 0, scalar($amper)); }
1239 | amper PERLY_PAREN_OPEN PERLY_PAREN_CLOSE /* &foo() or foo() */
1240 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($amper));
1242 | amper PERLY_PAREN_OPEN expr PERLY_PAREN_CLOSE /* &foo(@args) or foo(@args) */
1244 $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1245 op_append_elem(OP_LIST, $expr, scalar($amper)));
1247 | NOAMP subname optlistexpr /* foo @args (no parens) */
1248 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1249 op_append_elem(OP_LIST, $optlistexpr, scalar($subname)));
1251 | term[operand] ARROW PERLY_DOLLAR PERLY_STAR
1252 { $$ = newSVREF($operand); }
1253 | term[operand] ARROW PERLY_SNAIL PERLY_STAR
1254 { $$ = newAVREF($operand); }
1255 | term[operand] ARROW PERLY_PERCENT_SIGN PERLY_STAR
1256 { $$ = newHVREF($operand); }
1257 | term[operand] ARROW PERLY_AMPERSAND PERLY_STAR
1258 { $$ = newUNOP(OP_ENTERSUB, 0,
1259 scalar(newCVREF($PERLY_AMPERSAND,$operand))); }
1260 | term[operand] ARROW PERLY_STAR PERLY_STAR %prec PERLY_PAREN_OPEN
1261 { $$ = newGVREF(0,$operand); }
1262 | LOOPEX /* loop exiting command (goto, last, dump, etc) */
1263 { $$ = newOP($LOOPEX, OPf_SPECIAL);
1264 PL_hints |= HINT_BLOCK_SCOPE; }
1265 | LOOPEX term[operand]
1266 { $$ = newLOOPEX($LOOPEX,$operand); }
1267 | NOTOP listexpr /* not $foo */
1268 { $$ = newUNOP(OP_NOT, 0, scalar($listexpr)); }
1269 | UNIOP /* Unary op, $_ implied */
1270 { $$ = newOP($UNIOP, 0); }
1271 | UNIOP block /* eval { foo }* */
1272 { $$ = newUNOP($UNIOP, 0, $block); }
1273 | UNIOP term[operand] /* Unary op */
1274 { $$ = newUNOP($UNIOP, 0, $operand); }
1275 | REQUIRE /* require, $_ implied */
1276 { $$ = newOP(OP_REQUIRE, $REQUIRE ? OPf_SPECIAL : 0); }
1277 | REQUIRE term[operand] /* require Foo */
1278 { $$ = newUNOP(OP_REQUIRE, $REQUIRE ? OPf_SPECIAL : 0, $operand); }
1280 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($UNIOPSUB)); }
1281 | UNIOPSUB term[operand] /* Sub treated as unop */
1282 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1283 op_append_elem(OP_LIST, $operand, scalar($UNIOPSUB))); }
1284 | FUNC0 /* Nullary operator */
1285 { $$ = newOP($FUNC0, 0); }
1286 | FUNC0 PERLY_PAREN_OPEN PERLY_PAREN_CLOSE
1287 { $$ = newOP($FUNC0, 0);}
1288 | FUNC0OP /* Same as above, but op created in toke.c */
1290 | FUNC0OP PERLY_PAREN_OPEN PERLY_PAREN_CLOSE
1292 | FUNC0SUB /* Sub treated as nullop */
1293 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($FUNC0SUB)); }
1294 | FUNC1 PERLY_PAREN_OPEN PERLY_PAREN_CLOSE /* not () */
1295 { $$ = ($FUNC1 == OP_NOT)
1296 ? newUNOP($FUNC1, 0, newSVOP(OP_CONST, 0, newSViv(0)))
1297 : newOP($FUNC1, OPf_SPECIAL); }
1298 | FUNC1 PERLY_PAREN_OPEN expr PERLY_PAREN_CLOSE /* not($foo) */
1299 { $$ = newUNOP($FUNC1, 0, $expr); }
1300 | PMFUNC /* m//, s///, qr//, tr/// */
1302 if ( $PMFUNC->op_type != OP_TRANS
1303 && $PMFUNC->op_type != OP_TRANSR
1304 && (((PMOP*)$PMFUNC)->op_pmflags & PMf_HAS_CV))
1306 $<ival>$ = start_subparse(FALSE, CVf_ANON);
1307 SAVEFREESV(PL_compcv);
1311 SUBLEXSTART listexpr optrepl SUBLEXEND
1312 { $$ = pmruntime($PMFUNC, $listexpr, $optrepl, 1, $<ival>2); }
1318 /* "my" declarations, with optional attributes */
1319 myattrterm: MY myterm myattrlist
1320 { $$ = my_attrs($myterm,$myattrlist); }
1322 { $$ = localize($myterm,1); }
1323 | MY REFGEN myterm myattrlist
1324 { $$ = newUNOP(OP_REFGEN, 0, my_attrs($myterm,$myattrlist)); }
1327 /* Things that can be "my"'d */
1328 myterm : PERLY_PAREN_OPEN expr PERLY_PAREN_CLOSE
1329 { $$ = sawparens($expr); }
1330 | PERLY_PAREN_OPEN PERLY_PAREN_CLOSE
1331 { $$ = sawparens(newNULLLIST()); }
1333 | scalar %prec PERLY_PAREN_OPEN
1335 | hsh %prec PERLY_PAREN_OPEN
1337 | ary %prec PERLY_PAREN_OPEN
1341 /* Basic list expressions */
1342 optlistexpr: /* NULL */ %prec PREC_LOW
1344 | listexpr %prec PREC_LOW
1360 /* A little bit of trickery to make "for my $foo (@bar)" actually be
1363 { parser->in_my = 0; $$ = my($scalar); }
1371 refgen_topic: my_var
1375 my_refgen: MY REFGEN
1379 amper : PERLY_AMPERSAND indirob
1380 { $$ = newCVREF($PERLY_AMPERSAND,$indirob); }
1383 scalar : PERLY_DOLLAR indirob
1384 { $$ = newSVREF($indirob); }
1387 ary : PERLY_SNAIL indirob
1388 { $$ = newAVREF($indirob);
1389 if ($$) $$->op_private |= $PERLY_SNAIL;
1393 hsh : PERLY_PERCENT_SIGN indirob
1394 { $$ = newHVREF($indirob);
1395 if ($$) $$->op_private |= $PERLY_PERCENT_SIGN;
1399 arylen : DOLSHARP indirob
1400 { $$ = newAVREF($indirob); }
1401 | term ARROW DOLSHARP PERLY_STAR
1402 { $$ = newAVREF($term); }
1405 star : PERLY_STAR indirob
1406 { $$ = newGVREF(0,$indirob); }
1410 | term ARROW PERLY_SNAIL
1411 { $$ = newAVREF($term); }
1415 | term ARROW PERLY_PERCENT_SIGN
1416 { $$ = newHVREF($term); }
1420 | term ARROW PERLY_STAR
1421 { $$ = newGVREF(0,$term); }
1424 /* Indirect objects */
1426 { $$ = scalar($BAREWORD); }
1427 | scalar %prec PREC_LOW
1428 { $$ = scalar($scalar); }
1430 { $$ = op_scope($block); }
1433 { $$ = $PRIVATEREF; }