This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix a2p translation of '{print "a" "b" "c"}'
[perl5.git] / perly.y
CommitLineData
a0d0e21e 1/* perly.y
a687059c 2 *
a0d0e21e 3 * Copyright (c) 1991-1994, Larry Wall
a687059c 4 *
9ef589d8
LW
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
8d063cd8 7 *
a0d0e21e
LW
8 */
9
10/*
11 * 'I see,' laughed Strider. 'I look foul and feel fair. Is that it?
12 * All that is gold does not glitter, not all those that wander are lost.'
8d063cd8
LW
13 */
14
15%{
79072805 16#include "EXTERN.h"
8d063cd8 17#include "perl.h"
378cc40b 18
a0d0e21e
LW
19static void
20dep()
21{
22 deprecate("\"do\" to call subroutines");
23}
f0fcb552 24
8d063cd8
LW
25%}
26
27%start prog
28
29%union {
79072805
LW
30 I32 ival;
31 char *pval;
32 OP *opval;
33 GV *gvval;
8d063cd8
LW
34}
35
f0fcb552
LW
36%token <ival> '{' ')'
37
a0d0e21e 38%token <opval> WORD METHOD FUNCMETH THING PMFUNC PRIVATEREF
4633a7c4 39%token <opval> FUNC0SUB UNIOPSUB LSTOPSUB
79072805 40%token <pval> LABEL
a0d0e21e 41%token <ival> FORMAT SUB ANONSUB PACKAGE USE
79072805
LW
42%token <ival> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
43%token <ival> LOOPEX DOTDOT
44%token <ival> FUNC0 FUNC1 FUNC
45%token <ival> RELOP EQOP MULOP ADDOP
a0d0e21e 46%token <ival> DOLSHARP DO LOCAL HASHBRACK NOAMP
79072805 47
c07a80fd 48%type <ival> prog decl format remember startsub '&'
a0d0e21e
LW
49%type <opval> block lineseq line loop cond nexpr else argexpr
50%type <opval> expr term scalar ary hsh arylen star amper sideff
51%type <opval> listexpr listexprcom indirob
4633a7c4 52%type <opval> texpr listop method proto
79072805
LW
53%type <pval> label
54%type <opval> cont
55
a0d0e21e 56%left <ival> OROP
463ee0b2 57%left ANDOP
c07a80fd 58%right NOTOP
79072805 59%nonassoc <ival> LSTOP
8d063cd8 60%left ','
a0d0e21e 61%right <ival> ASSIGNOP
8d063cd8
LW
62%right '?' ':'
63%nonassoc DOTDOT
64%left OROR
65%left ANDAND
79072805
LW
66%left <ival> BITOROP
67%left <ival> BITANDOP
a687059c
LW
68%nonassoc EQOP
69%nonassoc RELOP
378cc40b 70%nonassoc <ival> UNIOP
79072805 71%left <ival> SHIFTOP
a687059c
LW
72%left ADDOP
73%left MULOP
8990e307 74%left <ival> MATCHOP
79072805
LW
75%right '!' '~' UMINUS REFGEN
76%right <ival> POWOP
77%nonassoc PREINC PREDEC POSTINC POSTDEC
8990e307 78%left ARROW
8d063cd8
LW
79%left '('
80
81%% /* RULES */
82
ae986130
LW
83prog : /* NULL */
84 {
85#if defined(YYDEBUG) && defined(DEBUGGING)
86 yydebug = (debug & 1);
87#endif
8990e307 88 expect = XSTATE;
ae986130
LW
89 }
90 /*CONTINUED*/ lineseq
a0d0e21e 91 { newPROG($2); }
8d063cd8
LW
92 ;
93
a687059c 94block : '{' remember lineseq '}'
a0d0e21e
LW
95 { $$ = block_end($1,$2,$3); }
96 ;
97
98remember: /* NULL */ /* start a lexical scope */
99 { $$ = block_start(); }
8d063cd8
LW
100 ;
101
102lineseq : /* NULL */
79072805
LW
103 { $$ = Nullop; }
104 | lineseq decl
105 { $$ = $1; }
8d063cd8 106 | lineseq line
463ee0b2 107 { $$ = append_list(OP_LINESEQ,
a0d0e21e
LW
108 (LISTOP*)$1, (LISTOP*)$2);
109 pad_reset_pending = TRUE;
85e6fe83 110 if ($1 && $2) hints |= HINT_BLOCK_SCOPE; }
8d063cd8
LW
111 ;
112
79072805
LW
113line : label cond
114 { $$ = newSTATEOP(0, $1, $2); }
8d063cd8
LW
115 | loop /* loops add their own labels */
116 | label ';'
117 { if ($1 != Nullch) {
79072805 118 $$ = newSTATEOP(0, $1, newOP(OP_NULL, 0));
450a55e4
LW
119 }
120 else {
79072805
LW
121 $$ = Nullop;
122 copline = NOLINE;
32c2e4fb 123 }
8990e307 124 expect = XSTATE; }
8d063cd8 125 | label sideff ';'
79072805 126 { $$ = newSTATEOP(0, $1, $2);
8990e307 127 expect = XSTATE; }
8d063cd8
LW
128 ;
129
a687059c 130sideff : error
79072805 131 { $$ = Nullop; }
a687059c 132 | expr
79072805 133 { $$ = $1; }
a687059c 134 | expr IF expr
79072805 135 { $$ = newLOGOP(OP_AND, 0, $3, $1); }
a687059c 136 | expr UNLESS expr
79072805 137 { $$ = newLOGOP(OP_OR, 0, $3, $1); }
a687059c 138 | expr WHILE expr
8990e307 139 { $$ = newLOOPOP(OPf_PARENS, 1, scalar($3), $1); }
a687059c 140 | expr UNTIL expr
8990e307 141 { $$ = newLOOPOP(OPf_PARENS, 1, invert(scalar($3)), $1);}
79072805
LW
142 ;
143
144else : /* NULL */
145 { $$ = Nullop; }
146 | ELSE block
147 { $$ = scope($2); }
148 | ELSIF '(' expr ')' block else
149 { copline = $1;
85e6fe83 150 $$ = newSTATEOP(0, 0,
4633a7c4
LW
151 newCONDOP(0, $3, scope($5), $6));
152 hints |= HINT_BLOCK_SCOPE; }
79072805
LW
153 ;
154
155cond : IF '(' expr ')' block else
156 { copline = $1;
157 $$ = newCONDOP(0, $3, scope($5), $6); }
158 | UNLESS '(' expr ')' block else
159 { copline = $1;
160 $$ = newCONDOP(0,
161 invert(scalar($3)), scope($5), $6); }
162 | IF block block else
163 { copline = $1;
a0d0e21e 164 deprecate("if BLOCK BLOCK");
79072805
LW
165 $$ = newCONDOP(0, scope($2), scope($3), $4); }
166 | UNLESS block block else
167 { copline = $1;
a0d0e21e 168 deprecate("unless BLOCK BLOCK");
79072805
LW
169 $$ = newCONDOP(0, invert(scalar(scope($2))),
170 scope($3), $4); }
171 ;
172
173cont : /* NULL */
174 { $$ = Nullop; }
175 | CONTINUE block
176 { $$ = scope($2); }
177 ;
178
179loop : label WHILE '(' texpr ')' block cont
180 { copline = $2;
181 $$ = newSTATEOP(0, $1,
463ee0b2
LW
182 newWHILEOP(0, 1, (LOOP*)Nullop,
183 $4, $6, $7) ); }
79072805
LW
184 | label UNTIL '(' expr ')' block cont
185 { copline = $2;
186 $$ = newSTATEOP(0, $1,
463ee0b2 187 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
188 invert(scalar($4)), $6, $7) ); }
189 | label WHILE block block cont
190 { copline = $2;
191 $$ = newSTATEOP(0, $1,
463ee0b2 192 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
193 scope($3), $4, $5) ); }
194 | label UNTIL block block cont
195 { copline = $2;
196 $$ = newSTATEOP(0, $1,
463ee0b2 197 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805 198 invert(scalar(scope($3))), $4, $5)); }
a0d0e21e 199 | label FOR scalar '(' expr ')' block cont
463ee0b2 200 { $$ = newFOROP(0, $1, $2, mod($3, OP_ENTERLOOP),
79072805 201 $5, $7, $8); }
a0d0e21e 202 | label FOR '(' expr ')' block cont
79072805 203 { $$ = newFOROP(0, $1, $2, Nullop, $4, $6, $7); }
8d063cd8
LW
204 | label FOR '(' nexpr ';' texpr ';' nexpr ')' block
205 /* basically fake up an initialize-while lineseq */
79072805
LW
206 { copline = $2;
207 $$ = append_elem(OP_LINESEQ,
208 newSTATEOP(0, $1, scalar($4)),
209 newSTATEOP(0, $1,
463ee0b2 210 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
211 scalar($6), $10, scalar($8)) )); }
212 | label block cont /* a block is a loop that happens once */
213 { $$ = newSTATEOP(0,
463ee0b2
LW
214 $1, newWHILEOP(0, 1, (LOOP*)Nullop,
215 Nullop, $2, $3)); }
8d063cd8
LW
216 ;
217
218nexpr : /* NULL */
79072805 219 { $$ = Nullop; }
8d063cd8
LW
220 | sideff
221 ;
222
223texpr : /* NULL means true */
79072805 224 { (void)scan_num("1"); $$ = yylval.opval; }
8d063cd8
LW
225 | expr
226 ;
227
228label : /* empty */
229 { $$ = Nullch; }
32c2e4fb 230 | LABEL
8d063cd8
LW
231 ;
232
8d063cd8
LW
233decl : format
234 { $$ = 0; }
235 | subrout
236 { $$ = 0; }
a687059c
LW
237 | package
238 { $$ = 0; }
a0d0e21e 239 | use
85e6fe83 240 { $$ = 0; }
8d063cd8
LW
241 ;
242
a0d0e21e
LW
243format : FORMAT startsub WORD block
244 { newFORM($2, $3, $4); }
245 | FORMAT startsub block
246 { newFORM($2, Nullop, $3); }
8d063cd8
LW
247 ;
248
4633a7c4
LW
249subrout : SUB startsub WORD proto block
250 { newSUB($2, $3, $4, $5); }
251 | SUB startsub WORD proto ';'
252 { newSUB($2, $3, $4, Nullop); expect = XSTATE; }
a0d0e21e
LW
253 ;
254
4633a7c4
LW
255proto : /* NULL */
256 { $$ = Nullop; }
257 | THING
258 ;
259
a0d0e21e
LW
260startsub: /* NULL */ /* start a subroutine scope */
261 { $$ = start_subparse(); }
8d063cd8
LW
262 ;
263
a687059c 264package : PACKAGE WORD ';'
79072805 265 { package($2); }
93a17b20
LW
266 | PACKAGE ';'
267 { package(Nullop); }
a687059c
LW
268 ;
269
62ac1c99
PP
270use : USE startsub WORD WORD listexpr ';'
271 { utilize($1, $2, $3, $4, $5); }
85e6fe83
LW
272 ;
273
a0d0e21e
LW
274expr : expr ANDOP expr
275 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
276 | expr OROP expr
277 { $$ = newLOGOP($2, 0, $1, $3); }
a0d0e21e
LW
278 | argexpr
279 ;
280
281argexpr : argexpr ','
282 { $$ = $1; }
283 | argexpr ',' term
79072805 284 { $$ = append_elem(OP_LIST, $1, $3); }
a0d0e21e 285 | term
8d063cd8
LW
286 ;
287
a0d0e21e 288listop : LSTOP indirob argexpr
79072805 289 { $$ = convert($1, OPf_STACKED,
a0d0e21e
LW
290 prepend_elem(OP_LIST, newGVREF($1,$2), $3) ); }
291 | FUNC '(' indirob expr ')'
79072805 292 { $$ = convert($1, OPf_STACKED,
a0d0e21e
LW
293 prepend_elem(OP_LIST, newGVREF($1,$3), $4) ); }
294 | term ARROW method '(' listexprcom ')'
4633a7c4 295 { $$ = convert(OP_ENTERSUB, OPf_STACKED,
a0d0e21e 296 append_elem(OP_LIST,
4633a7c4 297 prepend_elem(OP_LIST, $1, $5),
a0d0e21e 298 newUNOP(OP_METHOD, 0, $3))); }
79072805 299 | METHOD indirob listexpr
4633a7c4 300 { $$ = convert(OP_ENTERSUB, OPf_STACKED,
a0d0e21e 301 append_elem(OP_LIST,
4633a7c4 302 prepend_elem(OP_LIST, $2, $3),
a0d0e21e
LW
303 newUNOP(OP_METHOD, 0, $1))); }
304 | FUNCMETH indirob '(' listexprcom ')'
4633a7c4 305 { $$ = convert(OP_ENTERSUB, OPf_STACKED,
a0d0e21e 306 append_elem(OP_LIST,
4633a7c4 307 prepend_elem(OP_LIST, $2, $4),
a0d0e21e 308 newUNOP(OP_METHOD, 0, $1))); }
79072805
LW
309 | LSTOP listexpr
310 { $$ = convert($1, 0, $2); }
a0d0e21e 311 | FUNC '(' listexprcom ')'
79072805 312 { $$ = convert($1, 0, $3); }
4633a7c4
LW
313 | LSTOPSUB startsub block listexpr %prec LSTOP
314 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
315 append_elem(OP_LIST,
316 prepend_elem(OP_LIST, newANONSUB($2, 0, $3), $4),
317 $1)); }
a687059c
LW
318 ;
319
a0d0e21e
LW
320method : METHOD
321 | scalar
322 ;
323
324term : term ASSIGNOP term
325 { $$ = newASSIGNOP(OPf_STACKED, $1, $2, $3); }
326 | term POWOP term
79072805 327 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 328 | term MULOP term
79072805
LW
329 { if ($2 != OP_REPEAT)
330 scalar($1);
331 $$ = newBINOP($2, 0, $1, scalar($3)); }
a0d0e21e 332 | term ADDOP term
79072805 333 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 334 | term SHIFTOP term
79072805 335 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 336 | term RELOP term
79072805 337 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 338 | term EQOP term
79072805 339 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 340 | term BITANDOP term
79072805 341 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 342 | term BITOROP term
79072805 343 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 344 | term DOTDOT term
79072805 345 { $$ = newRANGE($2, scalar($1), scalar($3));}
a0d0e21e 346 | term ANDAND term
463ee0b2 347 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
a0d0e21e 348 | term OROR term
463ee0b2 349 { $$ = newLOGOP(OP_OR, 0, $1, $3); }
a0d0e21e 350 | term '?' term ':' term
79072805 351 { $$ = newCONDOP(0, $1, $3, $5); }
a0d0e21e 352 | term MATCHOP term
79072805 353 { $$ = bind_match($2, $1, $3); }
8d063cd8 354
a0d0e21e 355 | '-' term %prec UMINUS
79072805 356 { $$ = newUNOP(OP_NEGATE, 0, scalar($2)); }
a687059c
LW
357 | '+' term %prec UMINUS
358 { $$ = $2; }
8d063cd8 359 | '!' term
79072805 360 { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
8d063cd8 361 | '~' term
79072805
LW
362 { $$ = newUNOP(OP_COMPLEMENT, 0, scalar($2));}
363 | REFGEN term
a0d0e21e 364 { $$ = newUNOP(OP_REFGEN, 0, mod($2,OP_REFGEN)); }
79072805
LW
365 | term POSTINC
366 { $$ = newUNOP(OP_POSTINC, 0,
463ee0b2 367 mod(scalar($1), OP_POSTINC)); }
79072805
LW
368 | term POSTDEC
369 { $$ = newUNOP(OP_POSTDEC, 0,
463ee0b2 370 mod(scalar($1), OP_POSTDEC)); }
79072805
LW
371 | PREINC term
372 { $$ = newUNOP(OP_PREINC, 0,
463ee0b2 373 mod(scalar($2), OP_PREINC)); }
79072805
LW
374 | PREDEC term
375 { $$ = newUNOP(OP_PREDEC, 0,
463ee0b2 376 mod(scalar($2), OP_PREDEC)); }
a0d0e21e 377 | LOCAL term %prec UNIOP
93a17b20 378 { $$ = localize($2,$1); }
a0d0e21e 379 | '(' expr ')'
79072805 380 { $$ = sawparens($2); }
8d063cd8 381 | '(' ')'
8990e307 382 { $$ = sawparens(newNULLLIST()); }
a0d0e21e 383 | '[' expr ']' %prec '('
79072805
LW
384 { $$ = newANONLIST($2); }
385 | '[' ']' %prec '('
386 { $$ = newANONLIST(Nullop); }
a0d0e21e 387 | HASHBRACK expr ';' '}' %prec '('
79072805
LW
388 { $$ = newANONHASH($2); }
389 | HASHBRACK ';' '}' %prec '('
390 { $$ = newANONHASH(Nullop); }
4633a7c4
LW
391 | ANONSUB startsub proto block %prec '('
392 { $$ = newANONSUB($2, $3, $4); }
79072805 393 | scalar %prec '('
8d063cd8 394 { $$ = $1; }
c07a80fd
PP
395 | star '{' expr ';' '}'
396 { $$ = newBINOP(OP_GELEM, 0, newGVREF(0,$1), $3); }
79072805 397 | star %prec '('
8d063cd8 398 { $$ = $1; }
79072805
LW
399 | scalar '[' expr ']' %prec '('
400 { $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3)); }
401 | term ARROW '[' expr ']' %prec '('
402 { $$ = newBINOP(OP_AELEM, 0,
8990e307 403 ref(newAVREF($1),OP_RV2AV),
79072805 404 scalar($4));}
463ee0b2 405 | term '[' expr ']' %prec '('
a0d0e21e 406 { assertref($1); $$ = newBINOP(OP_AELEM, 0,
8990e307 407 ref(newAVREF($1),OP_RV2AV),
463ee0b2 408 scalar($3));}
79072805 409 | hsh %prec '('
8d063cd8 410 { $$ = $1; }
79072805 411 | ary %prec '('
8d063cd8 412 { $$ = $1; }
79072805
LW
413 | arylen %prec '('
414 { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));}
415 | scalar '{' expr ';' '}' %prec '('
416 { $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
417 expect = XOPERATOR; }
418 | term ARROW '{' expr ';' '}' %prec '('
419 { $$ = newBINOP(OP_HELEM, 0,
8990e307 420 ref(newHVREF($1),OP_RV2HV),
79072805
LW
421 jmaybe($4));
422 expect = XOPERATOR; }
463ee0b2 423 | term '{' expr ';' '}' %prec '('
a0d0e21e 424 { assertref($1); $$ = newBINOP(OP_HELEM, 0,
8990e307 425 ref(newHVREF($1),OP_RV2HV),
463ee0b2
LW
426 jmaybe($3));
427 expect = XOPERATOR; }
a0d0e21e 428 | '(' expr ')' '[' expr ']' %prec '('
79072805
LW
429 { $$ = newSLICEOP(0, $5, $2); }
430 | '(' ')' '[' expr ']' %prec '('
431 { $$ = newSLICEOP(0, $4, Nullop); }
432 | ary '[' expr ']' %prec '('
433 { $$ = prepend_elem(OP_ASLICE,
434 newOP(OP_PUSHMARK, 0),
79072805
LW
435 newLISTOP(OP_ASLICE, 0,
436 list($3),
a0d0e21e 437 ref($1, OP_ASLICE))); }
79072805
LW
438 | ary '{' expr ';' '}' %prec '('
439 { $$ = prepend_elem(OP_HSLICE,
440 newOP(OP_PUSHMARK, 0),
79072805
LW
441 newLISTOP(OP_HSLICE, 0,
442 list($3),
a0d0e21e 443 ref(oopsHV($1), OP_HSLICE)));
79072805
LW
444 expect = XOPERATOR; }
445 | THING %prec '('
446 { $$ = $1; }
447 | amper
c07a80fd 448 { $$ = newUNOP(OP_ENTERSUB, 0, scalar($1)); }
79072805 449 | amper '(' ')'
a0d0e21e
LW
450 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); }
451 | amper '(' expr ')'
452 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
4633a7c4 453 append_elem(OP_LIST, $3, scalar($1))); }
93a17b20 454 | NOAMP WORD listexpr
a0d0e21e 455 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
a5f75d66 456 append_elem(OP_LIST, $3, scalar($2))); }
a0d0e21e 457 | DO term %prec UNIOP
463ee0b2 458 { $$ = newUNOP(OP_DOFILE, 0, scalar($2)); }
79072805
LW
459 | DO block %prec '('
460 { $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); }
8d063cd8 461 | DO WORD '(' ')'
c07a80fd
PP
462 { $$ = newUNOP(OP_ENTERSUB,
463 OPf_SPECIAL|OPf_STACKED,
4633a7c4 464 prepend_elem(OP_LIST,
c07a80fd
PP
465 scalar(newCVREF(
466 (OPpENTERSUB_AMPER<<8),
467 scalar($2)
468 )),Nullop)); dep();}
a0d0e21e 469 | DO WORD '(' expr ')'
c07a80fd
PP
470 { $$ = newUNOP(OP_ENTERSUB,
471 OPf_SPECIAL|OPf_STACKED,
4633a7c4 472 append_elem(OP_LIST,
a0d0e21e 473 $4,
c07a80fd
PP
474 scalar(newCVREF(
475 (OPpENTERSUB_AMPER<<8),
476 scalar($2)
477 )))); dep();}
79072805 478 | DO scalar '(' ')'
a0d0e21e 479 { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
4633a7c4 480 prepend_elem(OP_LIST,
c07a80fd 481 scalar(newCVREF(0,scalar($2))), Nullop)); dep();}
a0d0e21e
LW
482 | DO scalar '(' expr ')'
483 { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
4633a7c4 484 prepend_elem(OP_LIST,
a0d0e21e 485 $4,
c07a80fd 486 scalar(newCVREF(0,scalar($2))))); dep();}
8d063cd8 487 | LOOPEX
85e6fe83
LW
488 { $$ = newOP($1, OPf_SPECIAL);
489 hints |= HINT_BLOCK_SCOPE; }
a0d0e21e 490 | LOOPEX term
8990e307 491 { $$ = newLOOPEX($1,$2); }
c07a80fd
PP
492 | NOTOP argexpr
493 { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
8d063cd8 494 | UNIOP
79072805 495 { $$ = newOP($1, 0); }
f0fcb552 496 | UNIOP block
79072805 497 { $$ = newUNOP($1, 0, $2); }
a0d0e21e 498 | UNIOP term
79072805 499 { $$ = newUNOP($1, 0, $2); }
4633a7c4
LW
500 | UNIOPSUB term
501 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
502 append_elem(OP_LIST, $2, scalar($1))); }
8d063cd8 503 | FUNC0
79072805 504 { $$ = newOP($1, 0); }
ae986130 505 | FUNC0 '(' ')'
79072805 506 { $$ = newOP($1, 0); }
4633a7c4
LW
507 | FUNC0SUB
508 { $$ = newUNOP(OP_ENTERSUB, 0,
509 scalar($1)); }
03a14243 510 | FUNC1 '(' ')'
79072805 511 { $$ = newOP($1, OPf_SPECIAL); }
8d063cd8 512 | FUNC1 '(' expr ')'
79072805 513 { $$ = newUNOP($1, 0, $3); }
a0d0e21e 514 | PMFUNC '(' term ')'
79072805 515 { $$ = pmruntime($1, $3, Nullop); }
a0d0e21e 516 | PMFUNC '(' term ',' term ')'
79072805
LW
517 { $$ = pmruntime($1, $3, $5); }
518 | WORD
378cc40b 519 | listop
8d063cd8
LW
520 ;
521
79072805 522listexpr: /* NULL */
8990e307 523 { $$ = Nullop; }
a0d0e21e
LW
524 | argexpr
525 { $$ = $1; }
526 ;
527
528listexprcom: /* NULL */
529 { $$ = Nullop; }
79072805
LW
530 | expr
531 { $$ = $1; }
a0d0e21e
LW
532 | expr ','
533 { $$ = $1; }
79072805
LW
534 ;
535
536amper : '&' indirob
c07a80fd 537 { $$ = newCVREF($1,$2); }
a687059c
LW
538 ;
539
79072805
LW
540scalar : '$' indirob
541 { $$ = newSVREF($2); }
a687059c
LW
542 ;
543
79072805
LW
544ary : '@' indirob
545 { $$ = newAVREF($2); }
546 ;
547
548hsh : '%' indirob
549 { $$ = newHVREF($2); }
550 ;
551
552arylen : DOLSHARP indirob
553 { $$ = newAVREF($2); }
554 ;
555
556star : '*' indirob
a0d0e21e 557 { $$ = newGVREF(0,$2); }
79072805
LW
558 ;
559
560indirob : WORD
561 { $$ = scalar($1); }
562 | scalar
463ee0b2 563 { $$ = scalar($1); }
79072805 564 | block
a0d0e21e 565 { $$ = scope($1); }
79072805 566
93a17b20
LW
567 | PRIVATEREF
568 { $$ = $1; }
8d063cd8
LW
569 ;
570
571%% /* PROGRAM */