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