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