This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.002beta2 patch: toke.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
a0d0e21e
LW
48%type <ival> prog decl format remember startsub
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
a0d0e21e 58%left 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
a0d0e21e
LW
270use : USE WORD listexpr ';'
271 { utilize($1, $2, $3); }
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); }
278 | NOTOP expr
279 { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
280 | argexpr
281 ;
282
283argexpr : argexpr ','
284 { $$ = $1; }
285 | argexpr ',' term
79072805 286 { $$ = append_elem(OP_LIST, $1, $3); }
a0d0e21e 287 | term
8d063cd8
LW
288 ;
289
a0d0e21e 290listop : LSTOP indirob argexpr
79072805 291 { $$ = convert($1, OPf_STACKED,
a0d0e21e
LW
292 prepend_elem(OP_LIST, newGVREF($1,$2), $3) ); }
293 | FUNC '(' indirob expr ')'
79072805 294 { $$ = convert($1, OPf_STACKED,
a0d0e21e
LW
295 prepend_elem(OP_LIST, newGVREF($1,$3), $4) ); }
296 | term ARROW method '(' listexprcom ')'
4633a7c4 297 { $$ = convert(OP_ENTERSUB, OPf_STACKED,
a0d0e21e 298 append_elem(OP_LIST,
4633a7c4 299 prepend_elem(OP_LIST, $1, $5),
a0d0e21e 300 newUNOP(OP_METHOD, 0, $3))); }
79072805 301 | METHOD indirob listexpr
4633a7c4 302 { $$ = convert(OP_ENTERSUB, OPf_STACKED,
a0d0e21e 303 append_elem(OP_LIST,
4633a7c4 304 prepend_elem(OP_LIST, $2, $3),
a0d0e21e
LW
305 newUNOP(OP_METHOD, 0, $1))); }
306 | FUNCMETH indirob '(' listexprcom ')'
4633a7c4 307 { $$ = convert(OP_ENTERSUB, OPf_STACKED,
a0d0e21e 308 append_elem(OP_LIST,
4633a7c4 309 prepend_elem(OP_LIST, $2, $4),
a0d0e21e 310 newUNOP(OP_METHOD, 0, $1))); }
79072805
LW
311 | LSTOP listexpr
312 { $$ = convert($1, 0, $2); }
a0d0e21e 313 | FUNC '(' listexprcom ')'
79072805 314 { $$ = convert($1, 0, $3); }
4633a7c4
LW
315 | LSTOPSUB startsub block listexpr %prec LSTOP
316 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
317 append_elem(OP_LIST,
318 prepend_elem(OP_LIST, newANONSUB($2, 0, $3), $4),
319 $1)); }
a687059c
LW
320 ;
321
a0d0e21e
LW
322method : METHOD
323 | scalar
324 ;
325
326term : term ASSIGNOP term
327 { $$ = newASSIGNOP(OPf_STACKED, $1, $2, $3); }
328 | term POWOP term
79072805 329 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 330 | term MULOP term
79072805
LW
331 { if ($2 != OP_REPEAT)
332 scalar($1);
333 $$ = newBINOP($2, 0, $1, scalar($3)); }
a0d0e21e 334 | term ADDOP term
79072805 335 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 336 | term SHIFTOP term
79072805 337 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 338 | term RELOP term
79072805 339 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 340 | term EQOP term
79072805 341 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 342 | term BITANDOP term
79072805 343 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 344 | term BITOROP term
79072805 345 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 346 | term DOTDOT term
79072805 347 { $$ = newRANGE($2, scalar($1), scalar($3));}
a0d0e21e 348 | term ANDAND term
463ee0b2 349 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
a0d0e21e 350 | term OROR term
463ee0b2 351 { $$ = newLOGOP(OP_OR, 0, $1, $3); }
a0d0e21e 352 | term '?' term ':' term
79072805 353 { $$ = newCONDOP(0, $1, $3, $5); }
a0d0e21e 354 | term MATCHOP term
79072805 355 { $$ = bind_match($2, $1, $3); }
8d063cd8 356
a0d0e21e 357 | '-' term %prec UMINUS
79072805 358 { $$ = newUNOP(OP_NEGATE, 0, scalar($2)); }
a687059c
LW
359 | '+' term %prec UMINUS
360 { $$ = $2; }
8d063cd8 361 | '!' term
79072805 362 { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
8d063cd8 363 | '~' term
79072805
LW
364 { $$ = newUNOP(OP_COMPLEMENT, 0, scalar($2));}
365 | REFGEN term
a0d0e21e 366 { $$ = newUNOP(OP_REFGEN, 0, mod($2,OP_REFGEN)); }
79072805
LW
367 | term POSTINC
368 { $$ = newUNOP(OP_POSTINC, 0,
463ee0b2 369 mod(scalar($1), OP_POSTINC)); }
79072805
LW
370 | term POSTDEC
371 { $$ = newUNOP(OP_POSTDEC, 0,
463ee0b2 372 mod(scalar($1), OP_POSTDEC)); }
79072805
LW
373 | PREINC term
374 { $$ = newUNOP(OP_PREINC, 0,
463ee0b2 375 mod(scalar($2), OP_PREINC)); }
79072805
LW
376 | PREDEC term
377 { $$ = newUNOP(OP_PREDEC, 0,
463ee0b2 378 mod(scalar($2), OP_PREDEC)); }
a0d0e21e 379 | LOCAL term %prec UNIOP
93a17b20 380 { $$ = localize($2,$1); }
a0d0e21e 381 | '(' expr ')'
79072805 382 { $$ = sawparens($2); }
8d063cd8 383 | '(' ')'
8990e307 384 { $$ = sawparens(newNULLLIST()); }
a0d0e21e 385 | '[' expr ']' %prec '('
79072805
LW
386 { $$ = newANONLIST($2); }
387 | '[' ']' %prec '('
388 { $$ = newANONLIST(Nullop); }
a0d0e21e 389 | HASHBRACK expr ';' '}' %prec '('
79072805
LW
390 { $$ = newANONHASH($2); }
391 | HASHBRACK ';' '}' %prec '('
392 { $$ = newANONHASH(Nullop); }
4633a7c4
LW
393 | ANONSUB startsub proto block %prec '('
394 { $$ = newANONSUB($2, $3, $4); }
79072805 395 | scalar %prec '('
8d063cd8 396 { $$ = $1; }
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
a0d0e21e 448 { $$ = newUNOP(OP_ENTERSUB, 0,
79072805
LW
449 scalar($1)); }
450 | amper '(' ')'
a0d0e21e
LW
451 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); }
452 | amper '(' expr ')'
453 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
4633a7c4 454 append_elem(OP_LIST, $3, scalar($1))); }
93a17b20 455 | NOAMP WORD listexpr
a0d0e21e 456 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
4633a7c4
LW
457 append_elem(OP_LIST,
458 $3, newCVREF(scalar($2)))); }
a0d0e21e 459 | DO term %prec UNIOP
463ee0b2 460 { $$ = newUNOP(OP_DOFILE, 0, scalar($2)); }
79072805
LW
461 | DO block %prec '('
462 { $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); }
8d063cd8 463 | DO WORD '(' ')'
a0d0e21e 464 { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
4633a7c4
LW
465 prepend_elem(OP_LIST,
466 scalar(newCVREF(scalar($2))), Nullop)); dep();}
a0d0e21e
LW
467 | DO WORD '(' expr ')'
468 { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
4633a7c4 469 append_elem(OP_LIST,
a0d0e21e 470 $4,
4633a7c4 471 scalar(newCVREF(scalar($2))))); dep();}
79072805 472 | DO scalar '(' ')'
a0d0e21e 473 { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
4633a7c4
LW
474 prepend_elem(OP_LIST,
475 scalar(newCVREF(scalar($2))), Nullop)); dep();}
a0d0e21e
LW
476 | DO scalar '(' expr ')'
477 { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
4633a7c4 478 prepend_elem(OP_LIST,
a0d0e21e 479 $4,
4633a7c4 480 scalar(newCVREF(scalar($2))))); dep();}
8d063cd8 481 | LOOPEX
85e6fe83
LW
482 { $$ = newOP($1, OPf_SPECIAL);
483 hints |= HINT_BLOCK_SCOPE; }
a0d0e21e 484 | LOOPEX term
8990e307 485 { $$ = newLOOPEX($1,$2); }
8d063cd8 486 | UNIOP
79072805 487 { $$ = newOP($1, 0); }
f0fcb552 488 | UNIOP block
79072805 489 { $$ = newUNOP($1, 0, $2); }
a0d0e21e 490 | UNIOP term
79072805 491 { $$ = newUNOP($1, 0, $2); }
4633a7c4
LW
492 | UNIOPSUB term
493 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
494 append_elem(OP_LIST, $2, scalar($1))); }
8d063cd8 495 | FUNC0
79072805 496 { $$ = newOP($1, 0); }
ae986130 497 | FUNC0 '(' ')'
79072805 498 { $$ = newOP($1, 0); }
4633a7c4
LW
499 | FUNC0SUB
500 { $$ = newUNOP(OP_ENTERSUB, 0,
501 scalar($1)); }
03a14243 502 | FUNC1 '(' ')'
79072805 503 { $$ = newOP($1, OPf_SPECIAL); }
8d063cd8 504 | FUNC1 '(' expr ')'
79072805 505 { $$ = newUNOP($1, 0, $3); }
a0d0e21e 506 | PMFUNC '(' term ')'
79072805 507 { $$ = pmruntime($1, $3, Nullop); }
a0d0e21e 508 | PMFUNC '(' term ',' term ')'
79072805
LW
509 { $$ = pmruntime($1, $3, $5); }
510 | WORD
378cc40b 511 | listop
8d063cd8
LW
512 ;
513
79072805 514listexpr: /* NULL */
8990e307 515 { $$ = Nullop; }
a0d0e21e
LW
516 | argexpr
517 { $$ = $1; }
518 ;
519
520listexprcom: /* NULL */
521 { $$ = Nullop; }
79072805
LW
522 | expr
523 { $$ = $1; }
a0d0e21e
LW
524 | expr ','
525 { $$ = $1; }
79072805
LW
526 ;
527
528amper : '&' indirob
529 { $$ = newCVREF($2); }
a687059c
LW
530 ;
531
79072805
LW
532scalar : '$' indirob
533 { $$ = newSVREF($2); }
a687059c
LW
534 ;
535
79072805
LW
536ary : '@' indirob
537 { $$ = newAVREF($2); }
538 ;
539
540hsh : '%' indirob
541 { $$ = newHVREF($2); }
542 ;
543
544arylen : DOLSHARP indirob
545 { $$ = newAVREF($2); }
546 ;
547
548star : '*' indirob
a0d0e21e 549 { $$ = newGVREF(0,$2); }
79072805
LW
550 ;
551
552indirob : WORD
553 { $$ = scalar($1); }
554 | scalar
463ee0b2 555 { $$ = scalar($1); }
79072805 556 | block
a0d0e21e 557 { $$ = scope($1); }
79072805 558
93a17b20
LW
559 | PRIVATEREF
560 { $$ = $1; }
8d063cd8
LW
561 ;
562
563%% /* PROGRAM */