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