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