This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 5
[perl5.git] / perly.y
CommitLineData
79072805 1/* $RCSfile: perly.y,v $$Revision: 4.1 $$Date: 92/08/07 18:26:16 $
a687059c 2 *
9ef589d8 3 * Copyright (c) 1991, 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 *
fe14fcc3 8 * $Log: perly.y,v $
79072805
LW
9 * Revision 4.1 92/08/07 18:26:16 lwall
10 *
faf8582f
LW
11 * Revision 4.0.1.5 92/06/11 21:12:50 lwall
12 * patch34: expectterm incorrectly set to indicate start of program or block
13 *
32c2e4fb
LW
14 * Revision 4.0.1.4 92/06/08 17:33:25 lwall
15 * patch20: one of the backdoors to expectterm was on the wrong reduction
16 *
17 * Revision 4.0.1.3 92/06/08 15:18:16 lwall
18 * patch20: an expression may now start with a bareword
19 * patch20: relaxed requirement for semicolon at the end of a block
20 * patch20: added ... as variant on ..
21 * patch20: fixed double debug break in foreach with implicit array assignment
22 * patch20: if {block} {block} didn't work any more
23 * patch20: deleted some minor memory leaks
24 *
f0fcb552
LW
25 * Revision 4.0.1.2 91/11/05 18:17:38 lwall
26 * patch11: extra comma at end of list is now allowed in more places (Hi, Felix!)
27 * patch11: once-thru blocks didn't display right in the debugger
28 * patch11: debugger got confused over nested subroutine definitions
29 *
9ef589d8
LW
30 * Revision 4.0.1.1 91/06/07 11:42:34 lwall
31 * patch4: new copyright notice
32 *
fe14fcc3
LW
33 * Revision 4.0 91/03/20 01:38:40 lwall
34 * 4.0 baseline.
8d063cd8
LW
35 *
36 */
37
38%{
79072805 39#include "EXTERN.h"
8d063cd8 40#include "perl.h"
378cc40b 41
f0fcb552
LW
42/*SUPPRESS 530*/
43/*SUPPRESS 593*/
44/*SUPPRESS 595*/
45
8d063cd8
LW
46%}
47
48%start prog
49
50%union {
79072805
LW
51 I32 ival;
52 char *pval;
53 OP *opval;
54 GV *gvval;
8d063cd8
LW
55}
56
f0fcb552
LW
57%token <ival> '{' ')'
58
93a17b20 59%token <opval> WORD METHOD THING PMFUNC PRIVATEREF
79072805
LW
60%token <pval> LABEL
61%token <ival> FORMAT SUB PACKAGE
62%token <ival> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
63%token <ival> LOOPEX DOTDOT
64%token <ival> FUNC0 FUNC1 FUNC
65%token <ival> RELOP EQOP MULOP ADDOP
93a17b20 66%token <ival> DOLSHARP DO LOCAL DELETE HASHBRACK NOAMP
79072805
LW
67
68%type <ival> prog decl format remember crp crb crhb
69%type <opval> block lineseq line loop cond nexpr else
70%type <opval> expr sexpr term scalar ary hsh arylen star amper sideff
71%type <opval> listexpr indirob
72%type <opval> texpr listop
73%type <pval> label
74%type <opval> cont
75
463ee0b2
LW
76%left OROP
77%left ANDOP
79072805 78%nonassoc <ival> LSTOP
8d063cd8 79%left ','
8d063cd8
LW
80%right '='
81%right '?' ':'
82%nonassoc DOTDOT
83%left OROR
84%left ANDAND
79072805
LW
85%left <ival> BITOROP
86%left <ival> BITANDOP
a687059c
LW
87%nonassoc EQOP
88%nonassoc RELOP
378cc40b 89%nonassoc <ival> UNIOP
79072805 90%left <ival> SHIFTOP
a687059c
LW
91%left ADDOP
92%left MULOP
79072805
LW
93%left <ival> MATCHOP ARROW
94%right '!' '~' UMINUS REFGEN
95%right <ival> POWOP
96%nonassoc PREINC PREDEC POSTINC POSTDEC
8d063cd8
LW
97%left '('
98
99%% /* RULES */
100
ae986130
LW
101prog : /* NULL */
102 {
103#if defined(YYDEBUG) && defined(DEBUGGING)
104 yydebug = (debug & 1);
105#endif
79072805 106 expect = XBLOCK;
ae986130
LW
107 }
108 /*CONTINUED*/ lineseq
79072805
LW
109 { if (in_eval) {
110 eval_root = newUNOP(OP_LEAVEEVAL, 0, $2);
111 eval_start = linklist(eval_root);
112 eval_root->op_next = 0;
113 peep(eval_start);
114 }
a559c259 115 else
93a17b20 116 main_root = block_head($2, &main_start);
79072805 117 }
8d063cd8
LW
118 ;
119
a687059c 120block : '{' remember lineseq '}'
463ee0b2
LW
121 { int nbs = needblockscope;
122 $$ = scalarseq($3);
123 if (copline > (line_t)$1)
124 copline = $1;
125 leave_scope($2);
126 if (nbs)
127 needblockscope = TRUE; /* propagate outward */
128 pad_leavemy(comppadnamefill); }
a687059c
LW
129 ;
130
131remember: /* NULL */ /* in case they push a package name */
463ee0b2
LW
132 { $$ = savestack_ix;
133 SAVEINT(comppadnamefill);
134 SAVEINT(needblockscope);
135 needblockscope = FALSE; }
8d063cd8
LW
136 ;
137
138lineseq : /* NULL */
79072805
LW
139 { $$ = Nullop; }
140 | lineseq decl
141 { $$ = $1; }
8d063cd8 142 | lineseq line
463ee0b2
LW
143 { $$ = append_list(OP_LINESEQ,
144 (LISTOP*)$1, (LISTOP*)$2); pad_reset();
145 if ($1 && $2) needblockscope = TRUE; }
8d063cd8
LW
146 ;
147
79072805
LW
148line : label cond
149 { $$ = newSTATEOP(0, $1, $2); }
8d063cd8
LW
150 | loop /* loops add their own labels */
151 | label ';'
152 { if ($1 != Nullch) {
79072805 153 $$ = newSTATEOP(0, $1, newOP(OP_NULL, 0));
450a55e4
LW
154 }
155 else {
79072805
LW
156 $$ = Nullop;
157 copline = NOLINE;
32c2e4fb 158 }
79072805 159 expect = XBLOCK; }
8d063cd8 160 | label sideff ';'
79072805
LW
161 { $$ = newSTATEOP(0, $1, $2);
162 expect = XBLOCK; }
8d063cd8
LW
163 ;
164
a687059c 165sideff : error
79072805 166 { $$ = Nullop; }
a687059c 167 | expr
79072805 168 { $$ = $1; }
a687059c 169 | expr IF expr
79072805 170 { $$ = newLOGOP(OP_AND, 0, $3, $1); }
a687059c 171 | expr UNLESS expr
79072805 172 { $$ = newLOGOP(OP_OR, 0, $3, $1); }
a687059c 173 | expr WHILE expr
93a17b20 174 { $$ = newLOOPOP(0, 1, scalar($3), $1); }
a687059c 175 | expr UNTIL expr
93a17b20 176 { $$ = newLOOPOP(0, 1, invert(scalar($3)), $1);}
79072805
LW
177 ;
178
179else : /* NULL */
180 { $$ = Nullop; }
181 | ELSE block
182 { $$ = scope($2); }
183 | ELSIF '(' expr ')' block else
184 { copline = $1;
185 $$ = newCONDOP(0, $3, scope($5), $6); }
186 ;
187
188cond : IF '(' expr ')' block else
189 { copline = $1;
190 $$ = newCONDOP(0, $3, scope($5), $6); }
191 | UNLESS '(' expr ')' block else
192 { copline = $1;
193 $$ = newCONDOP(0,
194 invert(scalar($3)), scope($5), $6); }
195 | IF block block else
196 { copline = $1;
197 $$ = newCONDOP(0, scope($2), scope($3), $4); }
198 | UNLESS block block else
199 { copline = $1;
200 $$ = newCONDOP(0, invert(scalar(scope($2))),
201 scope($3), $4); }
202 ;
203
204cont : /* NULL */
205 { $$ = Nullop; }
206 | CONTINUE block
207 { $$ = scope($2); }
208 ;
209
210loop : label WHILE '(' texpr ')' block cont
211 { copline = $2;
212 $$ = newSTATEOP(0, $1,
463ee0b2
LW
213 newWHILEOP(0, 1, (LOOP*)Nullop,
214 $4, $6, $7) ); }
79072805
LW
215 | label UNTIL '(' expr ')' block cont
216 { copline = $2;
217 $$ = newSTATEOP(0, $1,
463ee0b2 218 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
219 invert(scalar($4)), $6, $7) ); }
220 | label WHILE block block cont
221 { copline = $2;
222 $$ = newSTATEOP(0, $1,
463ee0b2 223 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
224 scope($3), $4, $5) ); }
225 | label UNTIL block block cont
226 { copline = $2;
227 $$ = newSTATEOP(0, $1,
463ee0b2 228 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
229 invert(scalar(scope($3))), $4, $5)); }
230 | label FOR scalar '(' expr crp block cont
463ee0b2 231 { $$ = newFOROP(0, $1, $2, mod($3, OP_ENTERLOOP),
79072805
LW
232 $5, $7, $8); }
233 | label FOR '(' expr crp block cont
234 { $$ = newFOROP(0, $1, $2, Nullop, $4, $6, $7); }
8d063cd8
LW
235 | label FOR '(' nexpr ';' texpr ';' nexpr ')' block
236 /* basically fake up an initialize-while lineseq */
79072805
LW
237 { copline = $2;
238 $$ = append_elem(OP_LINESEQ,
239 newSTATEOP(0, $1, scalar($4)),
240 newSTATEOP(0, $1,
463ee0b2 241 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
242 scalar($6), $10, scalar($8)) )); }
243 | label block cont /* a block is a loop that happens once */
244 { $$ = newSTATEOP(0,
463ee0b2
LW
245 $1, newWHILEOP(0, 1, (LOOP*)Nullop,
246 Nullop, $2, $3)); }
8d063cd8
LW
247 ;
248
249nexpr : /* NULL */
79072805 250 { $$ = Nullop; }
8d063cd8
LW
251 | sideff
252 ;
253
254texpr : /* NULL means true */
79072805 255 { (void)scan_num("1"); $$ = yylval.opval; }
8d063cd8
LW
256 | expr
257 ;
258
259label : /* empty */
260 { $$ = Nullch; }
32c2e4fb 261 | LABEL
8d063cd8
LW
262 ;
263
8d063cd8
LW
264decl : format
265 { $$ = 0; }
266 | subrout
267 { $$ = 0; }
a687059c
LW
268 | package
269 { $$ = 0; }
8d063cd8
LW
270 ;
271
79072805
LW
272format : FORMAT WORD block
273 { newFORM($1, $2, $3); }
274 | FORMAT block
275 { newFORM($1, Nullop, $2); }
8d063cd8
LW
276 ;
277
278subrout : SUB WORD block
79072805 279 { newSUB($1, $2, $3); }
93a17b20 280 | SUB WORD ';'
463ee0b2 281 { newSUB($1, $2, Nullop); expect = XBLOCK; }
8d063cd8
LW
282 ;
283
a687059c 284package : PACKAGE WORD ';'
79072805 285 { package($2); }
93a17b20
LW
286 | PACKAGE ';'
287 { package(Nullop); }
a687059c
LW
288 ;
289
290expr : expr ',' sexpr
79072805 291 { $$ = append_elem(OP_LIST, $1, $3); }
8d063cd8
LW
292 | sexpr
293 ;
294
79072805
LW
295listop : LSTOP indirob listexpr
296 { $$ = convert($1, OPf_STACKED,
297 prepend_elem(OP_LIST, newGVREF($2), $3) ); }
298 | FUNC '(' indirob listexpr ')'
299 { $$ = convert($1, OPf_STACKED,
300 prepend_elem(OP_LIST, newGVREF($3), $4) ); }
301 | indirob ARROW LSTOP listexpr
302 { $$ = convert($3, OPf_STACKED,
303 prepend_elem(OP_LIST, newGVREF($1), $4) ); }
304 | indirob ARROW FUNC '(' listexpr ')'
305 { $$ = convert($3, OPf_STACKED,
306 prepend_elem(OP_LIST, newGVREF($1), $5) ); }
307 | term ARROW METHOD '(' listexpr ')'
308 { $$ = convert(OP_ENTERSUBR, OPf_STACKED|OPf_SPECIAL,
309 prepend_elem(OP_LIST, newMETHOD($1,$3), $5)); }
310 | METHOD indirob listexpr
311 { $$ = convert(OP_ENTERSUBR, OPf_STACKED|OPf_SPECIAL,
312 prepend_elem(OP_LIST, newMETHOD($2,$1), $3)); }
313 | LSTOP listexpr
314 { $$ = convert($1, 0, $2); }
315 | FUNC '(' listexpr ')'
316 { $$ = convert($1, 0, $3); }
a687059c
LW
317 ;
318
8d063cd8 319sexpr : sexpr '=' sexpr
79072805
LW
320 { $$ = newASSIGNOP(OPf_STACKED, $1, $3); }
321 | sexpr POWOP '=' sexpr
322 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 323 mod(scalar($1), $2), scalar($4)); }
a687059c 324 | sexpr MULOP '=' sexpr
79072805 325 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 326 mod(scalar($1), $2), scalar($4)); }
a687059c 327 | sexpr ADDOP '=' sexpr
79072805 328 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 329 mod(scalar($1), $2), scalar($4));}
79072805
LW
330 | sexpr SHIFTOP '=' sexpr
331 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 332 mod(scalar($1), $2), scalar($4)); }
79072805
LW
333 | sexpr BITANDOP '=' sexpr
334 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 335 mod(scalar($1), $2), scalar($4)); }
79072805
LW
336 | sexpr BITOROP '=' sexpr
337 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 338 mod(scalar($1), $2), scalar($4)); }
79072805
LW
339 | sexpr ANDAND '=' sexpr
340 { $$ = newLOGOP(OP_ANDASSIGN, 0,
463ee0b2 341 mod(scalar($1), OP_ANDASSIGN),
79072805
LW
342 newUNOP(OP_SASSIGN, 0, scalar($4))); }
343 | sexpr OROR '=' sexpr
344 { $$ = newLOGOP(OP_ORASSIGN, 0,
463ee0b2 345 mod(scalar($1), OP_ORASSIGN),
79072805
LW
346 newUNOP(OP_SASSIGN, 0, scalar($4))); }
347
348
349 | sexpr POWOP sexpr
350 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a687059c 351 | sexpr MULOP sexpr
79072805
LW
352 { if ($2 != OP_REPEAT)
353 scalar($1);
354 $$ = newBINOP($2, 0, $1, scalar($3)); }
a687059c 355 | sexpr ADDOP sexpr
79072805
LW
356 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
357 | sexpr SHIFTOP sexpr
358 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a687059c 359 | sexpr RELOP sexpr
79072805 360 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a687059c 361 | sexpr EQOP sexpr
79072805
LW
362 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
363 | sexpr BITANDOP sexpr
364 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
365 | sexpr BITOROP sexpr
366 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
8d063cd8 367 | sexpr DOTDOT sexpr
79072805 368 { $$ = newRANGE($2, scalar($1), scalar($3));}
8d063cd8 369 | sexpr ANDAND sexpr
79072805 370 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
8d063cd8 371 | sexpr OROR sexpr
79072805 372 { $$ = newLOGOP(OP_OR, 0, $1, $3); }
463ee0b2
LW
373 | sexpr ANDOP sexpr
374 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
375 | sexpr OROP sexpr
376 { $$ = newLOGOP(OP_OR, 0, $1, $3); }
8d063cd8 377 | sexpr '?' sexpr ':' sexpr
79072805
LW
378 { $$ = newCONDOP(0, $1, $3, $5); }
379 | sexpr MATCHOP sexpr
380 { $$ = bind_match($2, $1, $3); }
8d063cd8
LW
381 | term
382 { $$ = $1; }
383 ;
384
385term : '-' term %prec UMINUS
79072805 386 { $$ = newUNOP(OP_NEGATE, 0, scalar($2)); }
a687059c
LW
387 | '+' term %prec UMINUS
388 { $$ = $2; }
8d063cd8 389 | '!' term
79072805 390 { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
8d063cd8 391 | '~' term
79072805
LW
392 { $$ = newUNOP(OP_COMPLEMENT, 0, scalar($2));}
393 | REFGEN term
463ee0b2 394 { $$ = newUNOP(OP_REFGEN, 0, mod($2,OP_REFGEN)); }
79072805
LW
395 | term POSTINC
396 { $$ = newUNOP(OP_POSTINC, 0,
463ee0b2 397 mod(scalar($1), OP_POSTINC)); }
79072805
LW
398 | term POSTDEC
399 { $$ = newUNOP(OP_POSTDEC, 0,
463ee0b2 400 mod(scalar($1), OP_POSTDEC)); }
79072805
LW
401 | PREINC term
402 { $$ = newUNOP(OP_PREINC, 0,
463ee0b2 403 mod(scalar($2), OP_PREINC)); }
79072805
LW
404 | PREDEC term
405 { $$ = newUNOP(OP_PREDEC, 0,
463ee0b2 406 mod(scalar($2), OP_PREDEC)); }
79072805 407 | LOCAL sexpr %prec UNIOP
93a17b20 408 { $$ = localize($2,$1); }
f0fcb552 409 | '(' expr crp
79072805 410 { $$ = sawparens($2); }
8d063cd8 411 | '(' ')'
79072805
LW
412 { $$ = newNULLLIST(); }
413 | '[' expr crb %prec '('
414 { $$ = newANONLIST($2); }
415 | '[' ']' %prec '('
416 { $$ = newANONLIST(Nullop); }
417 | HASHBRACK expr crhb %prec '('
418 { $$ = newANONHASH($2); }
419 | HASHBRACK ';' '}' %prec '('
420 { $$ = newANONHASH(Nullop); }
421 | scalar %prec '('
8d063cd8 422 { $$ = $1; }
79072805 423 | star %prec '('
8d063cd8 424 { $$ = $1; }
79072805
LW
425 | scalar '[' expr ']' %prec '('
426 { $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3)); }
427 | term ARROW '[' expr ']' %prec '('
428 { $$ = newBINOP(OP_AELEM, 0,
429 scalar(ref(newAVREF($1),OP_RV2AV)),
430 scalar($4));}
463ee0b2
LW
431 | term '[' expr ']' %prec '('
432 { $$ = newBINOP(OP_AELEM, 0,
433 scalar(ref(newAVREF($1),OP_RV2AV)),
434 scalar($3));}
79072805 435 | hsh %prec '('
8d063cd8 436 { $$ = $1; }
79072805 437 | ary %prec '('
8d063cd8 438 { $$ = $1; }
79072805
LW
439 | arylen %prec '('
440 { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));}
441 | scalar '{' expr ';' '}' %prec '('
442 { $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
443 expect = XOPERATOR; }
444 | term ARROW '{' expr ';' '}' %prec '('
445 { $$ = newBINOP(OP_HELEM, 0,
446 scalar(ref(newHVREF($1),OP_RV2HV)),
447 jmaybe($4));
448 expect = XOPERATOR; }
463ee0b2
LW
449 | term '{' expr ';' '}' %prec '('
450 { $$ = newBINOP(OP_HELEM, 0,
451 scalar(ref(newHVREF($1),OP_RV2HV)),
452 jmaybe($3));
453 expect = XOPERATOR; }
79072805
LW
454 | '(' expr crp '[' expr ']' %prec '('
455 { $$ = newSLICEOP(0, $5, $2); }
456 | '(' ')' '[' expr ']' %prec '('
457 { $$ = newSLICEOP(0, $4, Nullop); }
458 | ary '[' expr ']' %prec '('
459 { $$ = prepend_elem(OP_ASLICE,
460 newOP(OP_PUSHMARK, 0),
461 list(
462 newLISTOP(OP_ASLICE, 0,
463 list($3),
464 ref($1, OP_ASLICE)))); }
465 | ary '{' expr ';' '}' %prec '('
466 { $$ = prepend_elem(OP_HSLICE,
467 newOP(OP_PUSHMARK, 0),
468 list(
469 newLISTOP(OP_HSLICE, 0,
470 list($3),
471 ref(oopsHV($1), OP_HSLICE))));
472 expect = XOPERATOR; }
473 | DELETE scalar '{' expr ';' '}' %prec '('
474 { $$ = newBINOP(OP_DELETE, 0, oopsHV($2), jmaybe($4));
475 expect = XOPERATOR; }
476 | DELETE '(' scalar '{' expr ';' '}' ')' %prec '('
477 { $$ = newBINOP(OP_DELETE, 0, oopsHV($3), jmaybe($5));
478 expect = XOPERATOR; }
479 | THING %prec '('
480 { $$ = $1; }
481 | amper
482 { $$ = newUNOP(OP_ENTERSUBR, 0,
483 scalar($1)); }
484 | amper '(' ')'
485 { $$ = newUNOP(OP_ENTERSUBR, OPf_STACKED, scalar($1)); }
486 | amper '(' expr crp
487 { $$ = newUNOP(OP_ENTERSUBR, OPf_STACKED,
488 list(prepend_elem(OP_LIST, scalar($1), $3))); }
93a17b20
LW
489 | NOAMP WORD listexpr
490 { $$ = newUNOP(OP_ENTERSUBR, OPf_STACKED,
491 list(prepend_elem(OP_LIST,
492 newCVREF(scalar($2)), $3))); }
463ee0b2
LW
493 | NOAMP WORD indirob listexpr
494 { $$ = convert(OP_ENTERSUBR, OPf_STACKED|OPf_SPECIAL,
495 prepend_elem(OP_LIST, newMETHOD($3,$2), $4)); }
79072805 496 | DO sexpr %prec UNIOP
463ee0b2 497 { $$ = newUNOP(OP_DOFILE, 0, scalar($2)); }
79072805
LW
498 | DO block %prec '('
499 { $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); }
8d063cd8 500 | DO WORD '(' ')'
79072805
LW
501 { $$ = newUNOP(OP_ENTERSUBR, OPf_SPECIAL|OPf_STACKED,
502 list(prepend_elem(OP_LIST,
503 scalar(newCVREF(scalar($2))), newNULLLIST()))); }
504 | DO WORD '(' expr crp
505 { $$ = newUNOP(OP_ENTERSUBR, OPf_SPECIAL|OPf_STACKED,
506 list(prepend_elem(OP_LIST,
507 scalar(newCVREF(scalar($2))),
508 $4))); }
509 | DO scalar '(' ')'
510 { $$ = newUNOP(OP_ENTERSUBR, OPf_SPECIAL|OPf_STACKED,
511 list(prepend_elem(OP_LIST,
512 scalar(newCVREF(scalar($2))), newNULLLIST())));}
513 | DO scalar '(' expr crp
514 { $$ = newUNOP(OP_ENTERSUBR, OPf_SPECIAL|OPf_STACKED,
515 list(prepend_elem(OP_LIST,
516 scalar(newCVREF(scalar($2))),
517 $4))); }
8d063cd8 518 | LOOPEX
463ee0b2 519 { $$ = newOP($1, OPf_SPECIAL); needblockscope = TRUE; }
8d063cd8 520 | LOOPEX WORD
79072805 521 { $$ = newPVOP($1, 0,
463ee0b2
LW
522 savestr(SvPVx(((SVOP*)$2)->op_sv, na)));
523 op_free($2); needblockscope = TRUE; }
8d063cd8 524 | UNIOP
79072805 525 { $$ = newOP($1, 0); }
f0fcb552 526 | UNIOP block
79072805 527 { $$ = newUNOP($1, 0, $2); }
8d063cd8 528 | UNIOP sexpr
79072805 529 { $$ = newUNOP($1, 0, $2); }
8d063cd8 530 | FUNC0
79072805 531 { $$ = newOP($1, 0); }
ae986130 532 | FUNC0 '(' ')'
79072805 533 { $$ = newOP($1, 0); }
03a14243 534 | FUNC1 '(' ')'
79072805 535 { $$ = newOP($1, OPf_SPECIAL); }
8d063cd8 536 | FUNC1 '(' expr ')'
79072805
LW
537 { $$ = newUNOP($1, 0, $3); }
538 | PMFUNC '(' sexpr ')'
539 { $$ = pmruntime($1, $3, Nullop); }
540 | PMFUNC '(' sexpr ',' sexpr ')'
541 { $$ = pmruntime($1, $3, $5); }
542 | WORD
378cc40b 543 | listop
8d063cd8
LW
544 ;
545
79072805
LW
546listexpr: /* NULL */
547 { $$ = newNULLLIST(); }
548 | expr
549 { $$ = $1; }
550 ;
551
552amper : '&' indirob
553 { $$ = newCVREF($2); }
a687059c
LW
554 ;
555
79072805
LW
556scalar : '$' indirob
557 { $$ = newSVREF($2); }
a687059c
LW
558 ;
559
79072805
LW
560ary : '@' indirob
561 { $$ = newAVREF($2); }
562 ;
563
564hsh : '%' indirob
565 { $$ = newHVREF($2); }
566 ;
567
568arylen : DOLSHARP indirob
569 { $$ = newAVREF($2); }
570 ;
571
572star : '*' indirob
573 { $$ = newGVREF($2); }
574 ;
575
576indirob : WORD
577 { $$ = scalar($1); }
578 | scalar
463ee0b2 579 { $$ = scalar($1); }
79072805
LW
580 | block
581 { $$ = scalar(scope($1)); }
582
93a17b20
LW
583 | PRIVATEREF
584 { $$ = $1; }
8d063cd8
LW
585 ;
586
f0fcb552
LW
587crp : ',' ')'
588 { $$ = 1; }
589 | ')'
590 { $$ = 0; }
591 ;
592
79072805
LW
593crb : ',' ']'
594 { $$ = 1; }
595 | ']'
596 { $$ = 0; }
597 ;
598
599crhb : ',' ';' '}'
600 { $$ = 1; }
601 | ';' '}'
602 { $$ = 0; }
603 ;
450a55e4 604
8d063cd8 605%% /* PROGRAM */