This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 8
[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
8990e307 93%left <ival> MATCHOP
79072805
LW
94%right '!' '~' UMINUS REFGEN
95%right <ival> POWOP
96%nonassoc PREINC PREDEC POSTINC POSTDEC
8990e307 97%left ARROW
8d063cd8
LW
98%left '('
99
100%% /* RULES */
101
ae986130
LW
102prog : /* NULL */
103 {
104#if defined(YYDEBUG) && defined(DEBUGGING)
105 yydebug = (debug & 1);
106#endif
8990e307 107 expect = XSTATE;
ae986130
LW
108 }
109 /*CONTINUED*/ lineseq
79072805
LW
110 { if (in_eval) {
111 eval_root = newUNOP(OP_LEAVEEVAL, 0, $2);
112 eval_start = linklist(eval_root);
113 eval_root->op_next = 0;
114 peep(eval_start);
115 }
a559c259 116 else
93a17b20 117 main_root = block_head($2, &main_start);
79072805 118 }
8d063cd8
LW
119 ;
120
a687059c 121block : '{' remember lineseq '}'
463ee0b2
LW
122 { int nbs = needblockscope;
123 $$ = scalarseq($3);
124 if (copline > (line_t)$1)
125 copline = $1;
8990e307 126 LEAVE_SCOPE($2);
463ee0b2
LW
127 if (nbs)
128 needblockscope = TRUE; /* propagate outward */
8990e307 129 pad_leavemy(comppad_name_fill); }
a687059c
LW
130 ;
131
132remember: /* NULL */ /* in case they push a package name */
463ee0b2 133 { $$ = savestack_ix;
8990e307
LW
134 comppad_name_fill = AvFILL(comppad_name);
135 SAVEINT(min_intro_pending);
136 SAVEINT(max_intro_pending);
137 min_intro_pending = 0;
138 SAVEINT(comppad_name_fill);
463ee0b2
LW
139 SAVEINT(needblockscope);
140 needblockscope = FALSE; }
8d063cd8
LW
141 ;
142
143lineseq : /* NULL */
79072805
LW
144 { $$ = Nullop; }
145 | lineseq decl
146 { $$ = $1; }
8d063cd8 147 | lineseq line
463ee0b2
LW
148 { $$ = append_list(OP_LINESEQ,
149 (LISTOP*)$1, (LISTOP*)$2); pad_reset();
150 if ($1 && $2) needblockscope = TRUE; }
8d063cd8
LW
151 ;
152
79072805
LW
153line : label cond
154 { $$ = newSTATEOP(0, $1, $2); }
8d063cd8
LW
155 | loop /* loops add their own labels */
156 | label ';'
157 { if ($1 != Nullch) {
79072805 158 $$ = newSTATEOP(0, $1, newOP(OP_NULL, 0));
450a55e4
LW
159 }
160 else {
79072805
LW
161 $$ = Nullop;
162 copline = NOLINE;
32c2e4fb 163 }
8990e307 164 expect = XSTATE; }
8d063cd8 165 | label sideff ';'
79072805 166 { $$ = newSTATEOP(0, $1, $2);
8990e307 167 expect = XSTATE; }
8d063cd8
LW
168 ;
169
a687059c 170sideff : error
79072805 171 { $$ = Nullop; }
a687059c 172 | expr
79072805 173 { $$ = $1; }
a687059c 174 | expr IF expr
79072805 175 { $$ = newLOGOP(OP_AND, 0, $3, $1); }
a687059c 176 | expr UNLESS expr
79072805 177 { $$ = newLOGOP(OP_OR, 0, $3, $1); }
a687059c 178 | expr WHILE expr
8990e307 179 { $$ = newLOOPOP(OPf_PARENS, 1, scalar($3), $1); }
a687059c 180 | expr UNTIL expr
8990e307 181 { $$ = newLOOPOP(OPf_PARENS, 1, invert(scalar($3)), $1);}
79072805
LW
182 ;
183
184else : /* NULL */
185 { $$ = Nullop; }
186 | ELSE block
187 { $$ = scope($2); }
188 | ELSIF '(' expr ')' block else
189 { copline = $1;
190 $$ = newCONDOP(0, $3, scope($5), $6); }
191 ;
192
193cond : IF '(' expr ')' block else
194 { copline = $1;
195 $$ = newCONDOP(0, $3, scope($5), $6); }
196 | UNLESS '(' expr ')' block else
197 { copline = $1;
198 $$ = newCONDOP(0,
199 invert(scalar($3)), scope($5), $6); }
200 | IF block block else
201 { copline = $1;
202 $$ = newCONDOP(0, scope($2), scope($3), $4); }
203 | UNLESS block block else
204 { copline = $1;
205 $$ = newCONDOP(0, invert(scalar(scope($2))),
206 scope($3), $4); }
207 ;
208
209cont : /* NULL */
210 { $$ = Nullop; }
211 | CONTINUE block
212 { $$ = scope($2); }
213 ;
214
215loop : label WHILE '(' texpr ')' block cont
216 { copline = $2;
217 $$ = newSTATEOP(0, $1,
463ee0b2
LW
218 newWHILEOP(0, 1, (LOOP*)Nullop,
219 $4, $6, $7) ); }
79072805
LW
220 | label UNTIL '(' expr ')' block cont
221 { copline = $2;
222 $$ = newSTATEOP(0, $1,
463ee0b2 223 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
224 invert(scalar($4)), $6, $7) ); }
225 | label WHILE block block cont
226 { copline = $2;
227 $$ = newSTATEOP(0, $1,
463ee0b2 228 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
229 scope($3), $4, $5) ); }
230 | label UNTIL block block cont
231 { copline = $2;
232 $$ = newSTATEOP(0, $1,
463ee0b2 233 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
234 invert(scalar(scope($3))), $4, $5)); }
235 | label FOR scalar '(' expr crp block cont
463ee0b2 236 { $$ = newFOROP(0, $1, $2, mod($3, OP_ENTERLOOP),
79072805
LW
237 $5, $7, $8); }
238 | label FOR '(' expr crp block cont
239 { $$ = newFOROP(0, $1, $2, Nullop, $4, $6, $7); }
8d063cd8
LW
240 | label FOR '(' nexpr ';' texpr ';' nexpr ')' block
241 /* basically fake up an initialize-while lineseq */
79072805
LW
242 { copline = $2;
243 $$ = append_elem(OP_LINESEQ,
244 newSTATEOP(0, $1, scalar($4)),
245 newSTATEOP(0, $1,
463ee0b2 246 newWHILEOP(0, 1, (LOOP*)Nullop,
79072805
LW
247 scalar($6), $10, scalar($8)) )); }
248 | label block cont /* a block is a loop that happens once */
249 { $$ = newSTATEOP(0,
463ee0b2
LW
250 $1, newWHILEOP(0, 1, (LOOP*)Nullop,
251 Nullop, $2, $3)); }
8d063cd8
LW
252 ;
253
254nexpr : /* NULL */
79072805 255 { $$ = Nullop; }
8d063cd8
LW
256 | sideff
257 ;
258
259texpr : /* NULL means true */
79072805 260 { (void)scan_num("1"); $$ = yylval.opval; }
8d063cd8
LW
261 | expr
262 ;
263
264label : /* empty */
265 { $$ = Nullch; }
32c2e4fb 266 | LABEL
8d063cd8
LW
267 ;
268
8d063cd8
LW
269decl : format
270 { $$ = 0; }
271 | subrout
272 { $$ = 0; }
a687059c
LW
273 | package
274 { $$ = 0; }
8d063cd8
LW
275 ;
276
79072805
LW
277format : FORMAT WORD block
278 { newFORM($1, $2, $3); }
279 | FORMAT block
280 { newFORM($1, Nullop, $2); }
8d063cd8
LW
281 ;
282
283subrout : SUB WORD block
79072805 284 { newSUB($1, $2, $3); }
93a17b20 285 | SUB WORD ';'
8990e307 286 { newSUB($1, $2, Nullop); expect = XSTATE; }
8d063cd8
LW
287 ;
288
a687059c 289package : PACKAGE WORD ';'
79072805 290 { package($2); }
93a17b20
LW
291 | PACKAGE ';'
292 { package(Nullop); }
a687059c
LW
293 ;
294
295expr : expr ',' sexpr
79072805 296 { $$ = append_elem(OP_LIST, $1, $3); }
8d063cd8
LW
297 | sexpr
298 ;
299
79072805
LW
300listop : LSTOP indirob listexpr
301 { $$ = convert($1, OPf_STACKED,
302 prepend_elem(OP_LIST, newGVREF($2), $3) ); }
303 | FUNC '(' indirob listexpr ')'
304 { $$ = convert($1, OPf_STACKED,
305 prepend_elem(OP_LIST, newGVREF($3), $4) ); }
306 | indirob ARROW LSTOP listexpr
307 { $$ = convert($3, OPf_STACKED,
308 prepend_elem(OP_LIST, newGVREF($1), $4) ); }
309 | indirob ARROW FUNC '(' listexpr ')'
310 { $$ = convert($3, OPf_STACKED,
311 prepend_elem(OP_LIST, newGVREF($1), $5) ); }
312 | term ARROW METHOD '(' listexpr ')'
313 { $$ = convert(OP_ENTERSUBR, OPf_STACKED|OPf_SPECIAL,
8990e307
LW
314 prepend_elem(OP_LIST,
315 newMETHOD($1,$3), list($5))); }
79072805
LW
316 | METHOD indirob listexpr
317 { $$ = convert(OP_ENTERSUBR, OPf_STACKED|OPf_SPECIAL,
8990e307
LW
318 prepend_elem(OP_LIST,
319 newMETHOD($2,$1), list($3))); }
79072805
LW
320 | LSTOP listexpr
321 { $$ = convert($1, 0, $2); }
322 | FUNC '(' listexpr ')'
323 { $$ = convert($1, 0, $3); }
a687059c
LW
324 ;
325
8d063cd8 326sexpr : sexpr '=' sexpr
79072805
LW
327 { $$ = newASSIGNOP(OPf_STACKED, $1, $3); }
328 | sexpr POWOP '=' sexpr
329 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 330 mod(scalar($1), $2), scalar($4)); }
a687059c 331 | sexpr MULOP '=' sexpr
79072805 332 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 333 mod(scalar($1), $2), scalar($4)); }
a687059c 334 | sexpr ADDOP '=' sexpr
79072805 335 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 336 mod(scalar($1), $2), scalar($4));}
79072805
LW
337 | sexpr SHIFTOP '=' sexpr
338 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 339 mod(scalar($1), $2), scalar($4)); }
79072805
LW
340 | sexpr BITANDOP '=' sexpr
341 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 342 mod(scalar($1), $2), scalar($4)); }
79072805
LW
343 | sexpr BITOROP '=' sexpr
344 { $$ = newBINOP($2, OPf_STACKED,
463ee0b2 345 mod(scalar($1), $2), scalar($4)); }
79072805
LW
346 | sexpr ANDAND '=' sexpr
347 { $$ = newLOGOP(OP_ANDASSIGN, 0,
463ee0b2 348 mod(scalar($1), OP_ANDASSIGN),
79072805
LW
349 newUNOP(OP_SASSIGN, 0, scalar($4))); }
350 | sexpr OROR '=' sexpr
351 { $$ = newLOGOP(OP_ORASSIGN, 0,
463ee0b2 352 mod(scalar($1), OP_ORASSIGN),
79072805
LW
353 newUNOP(OP_SASSIGN, 0, scalar($4))); }
354
355
356 | sexpr POWOP sexpr
357 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a687059c 358 | sexpr MULOP sexpr
79072805
LW
359 { if ($2 != OP_REPEAT)
360 scalar($1);
361 $$ = newBINOP($2, 0, $1, scalar($3)); }
a687059c 362 | sexpr ADDOP sexpr
79072805
LW
363 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
364 | sexpr SHIFTOP sexpr
365 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a687059c 366 | sexpr RELOP sexpr
79072805 367 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a687059c 368 | sexpr EQOP sexpr
79072805
LW
369 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
370 | sexpr BITANDOP sexpr
371 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
372 | sexpr BITOROP sexpr
373 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
8d063cd8 374 | sexpr DOTDOT sexpr
79072805 375 { $$ = newRANGE($2, scalar($1), scalar($3));}
8d063cd8 376 | sexpr ANDAND sexpr
79072805 377 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
8d063cd8 378 | sexpr OROR sexpr
79072805 379 { $$ = newLOGOP(OP_OR, 0, $1, $3); }
463ee0b2
LW
380 | sexpr ANDOP sexpr
381 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
382 | sexpr OROP sexpr
383 { $$ = newLOGOP(OP_OR, 0, $1, $3); }
8d063cd8 384 | sexpr '?' sexpr ':' sexpr
79072805
LW
385 { $$ = newCONDOP(0, $1, $3, $5); }
386 | sexpr MATCHOP sexpr
387 { $$ = bind_match($2, $1, $3); }
8d063cd8
LW
388 | term
389 { $$ = $1; }
390 ;
391
392term : '-' term %prec UMINUS
79072805 393 { $$ = newUNOP(OP_NEGATE, 0, scalar($2)); }
a687059c
LW
394 | '+' term %prec UMINUS
395 { $$ = $2; }
8d063cd8 396 | '!' term
79072805 397 { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
8d063cd8 398 | '~' term
79072805
LW
399 { $$ = newUNOP(OP_COMPLEMENT, 0, scalar($2));}
400 | REFGEN term
8990e307 401 { $$ = newUNOP(OP_REFGEN, 0, ref($2,OP_REFGEN)); }
79072805
LW
402 | term POSTINC
403 { $$ = newUNOP(OP_POSTINC, 0,
463ee0b2 404 mod(scalar($1), OP_POSTINC)); }
79072805
LW
405 | term POSTDEC
406 { $$ = newUNOP(OP_POSTDEC, 0,
463ee0b2 407 mod(scalar($1), OP_POSTDEC)); }
79072805
LW
408 | PREINC term
409 { $$ = newUNOP(OP_PREINC, 0,
463ee0b2 410 mod(scalar($2), OP_PREINC)); }
79072805
LW
411 | PREDEC term
412 { $$ = newUNOP(OP_PREDEC, 0,
463ee0b2 413 mod(scalar($2), OP_PREDEC)); }
79072805 414 | LOCAL sexpr %prec UNIOP
93a17b20 415 { $$ = localize($2,$1); }
f0fcb552 416 | '(' expr crp
79072805 417 { $$ = sawparens($2); }
8d063cd8 418 | '(' ')'
8990e307 419 { $$ = sawparens(newNULLLIST()); }
79072805
LW
420 | '[' expr crb %prec '('
421 { $$ = newANONLIST($2); }
422 | '[' ']' %prec '('
423 { $$ = newANONLIST(Nullop); }
424 | HASHBRACK expr crhb %prec '('
425 { $$ = newANONHASH($2); }
426 | HASHBRACK ';' '}' %prec '('
427 { $$ = newANONHASH(Nullop); }
428 | scalar %prec '('
8d063cd8 429 { $$ = $1; }
79072805 430 | star %prec '('
8d063cd8 431 { $$ = $1; }
79072805
LW
432 | scalar '[' expr ']' %prec '('
433 { $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3)); }
434 | term ARROW '[' expr ']' %prec '('
435 { $$ = newBINOP(OP_AELEM, 0,
8990e307 436 ref(newAVREF($1),OP_RV2AV),
79072805 437 scalar($4));}
463ee0b2
LW
438 | term '[' expr ']' %prec '('
439 { $$ = newBINOP(OP_AELEM, 0,
8990e307 440 ref(newAVREF($1),OP_RV2AV),
463ee0b2 441 scalar($3));}
79072805 442 | hsh %prec '('
8d063cd8 443 { $$ = $1; }
79072805 444 | ary %prec '('
8d063cd8 445 { $$ = $1; }
79072805
LW
446 | arylen %prec '('
447 { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));}
448 | scalar '{' expr ';' '}' %prec '('
449 { $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
450 expect = XOPERATOR; }
451 | term ARROW '{' expr ';' '}' %prec '('
452 { $$ = newBINOP(OP_HELEM, 0,
8990e307 453 ref(newHVREF($1),OP_RV2HV),
79072805
LW
454 jmaybe($4));
455 expect = XOPERATOR; }
463ee0b2
LW
456 | term '{' expr ';' '}' %prec '('
457 { $$ = newBINOP(OP_HELEM, 0,
8990e307 458 ref(newHVREF($1),OP_RV2HV),
463ee0b2
LW
459 jmaybe($3));
460 expect = XOPERATOR; }
79072805
LW
461 | '(' expr crp '[' expr ']' %prec '('
462 { $$ = newSLICEOP(0, $5, $2); }
463 | '(' ')' '[' expr ']' %prec '('
464 { $$ = newSLICEOP(0, $4, Nullop); }
465 | ary '[' expr ']' %prec '('
466 { $$ = prepend_elem(OP_ASLICE,
467 newOP(OP_PUSHMARK, 0),
468 list(
469 newLISTOP(OP_ASLICE, 0,
470 list($3),
471 ref($1, OP_ASLICE)))); }
472 | ary '{' expr ';' '}' %prec '('
473 { $$ = prepend_elem(OP_HSLICE,
474 newOP(OP_PUSHMARK, 0),
475 list(
476 newLISTOP(OP_HSLICE, 0,
477 list($3),
478 ref(oopsHV($1), OP_HSLICE))));
479 expect = XOPERATOR; }
480 | DELETE scalar '{' expr ';' '}' %prec '('
481 { $$ = newBINOP(OP_DELETE, 0, oopsHV($2), jmaybe($4));
482 expect = XOPERATOR; }
483 | DELETE '(' scalar '{' expr ';' '}' ')' %prec '('
484 { $$ = newBINOP(OP_DELETE, 0, oopsHV($3), jmaybe($5));
485 expect = XOPERATOR; }
486 | THING %prec '('
487 { $$ = $1; }
488 | amper
489 { $$ = newUNOP(OP_ENTERSUBR, 0,
490 scalar($1)); }
491 | amper '(' ')'
492 { $$ = newUNOP(OP_ENTERSUBR, OPf_STACKED, scalar($1)); }
493 | amper '(' expr crp
494 { $$ = newUNOP(OP_ENTERSUBR, OPf_STACKED,
495 list(prepend_elem(OP_LIST, scalar($1), $3))); }
93a17b20
LW
496 | NOAMP WORD listexpr
497 { $$ = newUNOP(OP_ENTERSUBR, OPf_STACKED,
498 list(prepend_elem(OP_LIST,
499 newCVREF(scalar($2)), $3))); }
463ee0b2
LW
500 | NOAMP WORD indirob listexpr
501 { $$ = convert(OP_ENTERSUBR, OPf_STACKED|OPf_SPECIAL,
8990e307
LW
502 prepend_elem(OP_LIST,
503 newMETHOD($3,$2), list($4))); }
79072805 504 | DO sexpr %prec UNIOP
463ee0b2 505 { $$ = newUNOP(OP_DOFILE, 0, scalar($2)); }
79072805
LW
506 | DO block %prec '('
507 { $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); }
8d063cd8 508 | DO WORD '(' ')'
79072805
LW
509 { $$ = newUNOP(OP_ENTERSUBR, OPf_SPECIAL|OPf_STACKED,
510 list(prepend_elem(OP_LIST,
8990e307 511 scalar(newCVREF(scalar($2))), Nullop))); }
79072805
LW
512 | DO WORD '(' expr crp
513 { $$ = newUNOP(OP_ENTERSUBR, OPf_SPECIAL|OPf_STACKED,
514 list(prepend_elem(OP_LIST,
515 scalar(newCVREF(scalar($2))),
516 $4))); }
517 | DO scalar '(' ')'
518 { $$ = newUNOP(OP_ENTERSUBR, OPf_SPECIAL|OPf_STACKED,
519 list(prepend_elem(OP_LIST,
8990e307 520 scalar(newCVREF(scalar($2))), Nullop)));}
79072805
LW
521 | DO scalar '(' expr crp
522 { $$ = newUNOP(OP_ENTERSUBR, OPf_SPECIAL|OPf_STACKED,
523 list(prepend_elem(OP_LIST,
524 scalar(newCVREF(scalar($2))),
525 $4))); }
8d063cd8 526 | LOOPEX
463ee0b2 527 { $$ = newOP($1, OPf_SPECIAL); needblockscope = TRUE; }
8990e307
LW
528 | LOOPEX sexpr
529 { $$ = newLOOPEX($1,$2); }
8d063cd8 530 | UNIOP
79072805 531 { $$ = newOP($1, 0); }
f0fcb552 532 | UNIOP block
79072805 533 { $$ = newUNOP($1, 0, $2); }
8d063cd8 534 | UNIOP sexpr
79072805 535 { $$ = newUNOP($1, 0, $2); }
8d063cd8 536 | FUNC0
79072805 537 { $$ = newOP($1, 0); }
ae986130 538 | FUNC0 '(' ')'
79072805 539 { $$ = newOP($1, 0); }
03a14243 540 | FUNC1 '(' ')'
79072805 541 { $$ = newOP($1, OPf_SPECIAL); }
8d063cd8 542 | FUNC1 '(' expr ')'
79072805
LW
543 { $$ = newUNOP($1, 0, $3); }
544 | PMFUNC '(' sexpr ')'
545 { $$ = pmruntime($1, $3, Nullop); }
546 | PMFUNC '(' sexpr ',' sexpr ')'
547 { $$ = pmruntime($1, $3, $5); }
548 | WORD
378cc40b 549 | listop
8d063cd8
LW
550 ;
551
79072805 552listexpr: /* NULL */
8990e307 553 { $$ = Nullop; }
79072805
LW
554 | expr
555 { $$ = $1; }
556 ;
557
558amper : '&' indirob
559 { $$ = newCVREF($2); }
a687059c
LW
560 ;
561
79072805
LW
562scalar : '$' indirob
563 { $$ = newSVREF($2); }
a687059c
LW
564 ;
565
79072805
LW
566ary : '@' indirob
567 { $$ = newAVREF($2); }
568 ;
569
570hsh : '%' indirob
571 { $$ = newHVREF($2); }
572 ;
573
574arylen : DOLSHARP indirob
575 { $$ = newAVREF($2); }
576 ;
577
578star : '*' indirob
579 { $$ = newGVREF($2); }
580 ;
581
582indirob : WORD
583 { $$ = scalar($1); }
584 | scalar
463ee0b2 585 { $$ = scalar($1); }
79072805
LW
586 | block
587 { $$ = scalar(scope($1)); }
588
93a17b20
LW
589 | PRIVATEREF
590 { $$ = $1; }
8d063cd8
LW
591 ;
592
f0fcb552
LW
593crp : ',' ')'
594 { $$ = 1; }
595 | ')'
596 { $$ = 0; }
597 ;
598
79072805
LW
599crb : ',' ']'
600 { $$ = 1; }
601 | ']'
602 { $$ = 0; }
603 ;
604
605crhb : ',' ';' '}'
606 { $$ = 1; }
607 | ';' '}'
608 { $$ = 0; }
609 ;
450a55e4 610
8d063cd8 611%% /* PROGRAM */