This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: 5.004_65 uninitialized variable regexec.c (2)
[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, newGVREF(0,$1),
446                                         scalar($3)); }
447         |       star    %prec '('
448                         { $$ = $1; }
449         |       scalar '[' expr ']'     %prec '('
450                         { $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3)); }
451         |       term ARROW '[' expr ']' %prec '('
452                         { $$ = newBINOP(OP_AELEM, 0,
453                                         ref(newAVREF($1),OP_RV2AV),
454                                         scalar($4));}
455         |       term '[' expr ']'       %prec '('
456                         { assertref($1); $$ = newBINOP(OP_AELEM, 0,
457                                         ref(newAVREF($1),OP_RV2AV),
458                                         scalar($3));}
459         |       hsh     %prec '('
460                         { $$ = $1; }
461         |       ary     %prec '('
462                         { $$ = $1; }
463         |       arylen  %prec '('
464                         { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));}
465         |       scalar '{' expr ';' '}' %prec '('
466                         { $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
467                             expect = XOPERATOR; }
468         |       term ARROW '{' expr ';' '}'     %prec '('
469                         { $$ = newBINOP(OP_HELEM, 0,
470                                         ref(newHVREF($1),OP_RV2HV),
471                                         jmaybe($4));
472                             expect = XOPERATOR; }
473         |       term '{' expr ';' '}'   %prec '('
474                         { assertref($1); $$ = newBINOP(OP_HELEM, 0,
475                                         ref(newHVREF($1),OP_RV2HV),
476                                         jmaybe($3));
477                             expect = XOPERATOR; }
478         |       '(' expr ')' '[' expr ']'       %prec '('
479                         { $$ = newSLICEOP(0, $5, $2); }
480         |       '(' ')' '[' expr ']'    %prec '('
481                         { $$ = newSLICEOP(0, $4, Nullop); }
482         |       ary '[' expr ']'        %prec '('
483                         { $$ = prepend_elem(OP_ASLICE,
484                                 newOP(OP_PUSHMARK, 0),
485                                     newLISTOP(OP_ASLICE, 0,
486                                         list($3),
487                                         ref($1, OP_ASLICE))); }
488         |       ary '{' expr ';' '}'    %prec '('
489                         { $$ = prepend_elem(OP_HSLICE,
490                                 newOP(OP_PUSHMARK, 0),
491                                     newLISTOP(OP_HSLICE, 0,
492                                         list($3),
493                                         ref(oopsHV($1), OP_HSLICE)));
494                             expect = XOPERATOR; }
495         |       THING   %prec '('
496                         { $$ = $1; }
497         |       amper
498                         { $$ = newUNOP(OP_ENTERSUB, 0, scalar($1)); }
499         |       amper '(' ')'
500                         { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); }
501         |       amper '(' expr ')'
502                         { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
503                             append_elem(OP_LIST, $3, scalar($1))); }
504         |       NOAMP WORD listexpr
505                         { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
506                             append_elem(OP_LIST, $3, scalar($2))); }
507         |       DO term %prec UNIOP
508                         { $$ = newUNOP(OP_DOFILE, 0, scalar($2)); }
509         |       DO block        %prec '('
510                         { $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); }
511         |       DO WORD '(' ')'
512                         { $$ = newUNOP(OP_ENTERSUB,
513                             OPf_SPECIAL|OPf_STACKED,
514                             prepend_elem(OP_LIST,
515                                 scalar(newCVREF(
516                                     (OPpENTERSUB_AMPER<<8),
517                                     scalar($2)
518                                 )),Nullop)); dep();}
519         |       DO WORD '(' expr ')'
520                         { $$ = newUNOP(OP_ENTERSUB,
521                             OPf_SPECIAL|OPf_STACKED,
522                             append_elem(OP_LIST,
523                                 $4,
524                                 scalar(newCVREF(
525                                     (OPpENTERSUB_AMPER<<8),
526                                     scalar($2)
527                                 )))); dep();}
528         |       DO scalar '(' ')'
529                         { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
530                             prepend_elem(OP_LIST,
531                                 scalar(newCVREF(0,scalar($2))), Nullop)); dep();}
532         |       DO scalar '(' expr ')'
533                         { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
534                             prepend_elem(OP_LIST,
535                                 $4,
536                                 scalar(newCVREF(0,scalar($2))))); dep();}
537         |       term ARROW '(' ')'      %prec '('
538                         { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
539                                    newCVREF(0, scalar($1))); }
540         |       term ARROW '(' expr ')' %prec '('
541                         { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
542                                    append_elem(OP_LIST, $4,
543                                        newCVREF(0, scalar($1)))); }
544         |       LOOPEX
545                         { $$ = newOP($1, OPf_SPECIAL);
546                             hints |= HINT_BLOCK_SCOPE; }
547         |       LOOPEX term
548                         { $$ = newLOOPEX($1,$2); }
549         |       NOTOP argexpr
550                         { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
551         |       UNIOP
552                         { $$ = newOP($1, 0); }
553         |       UNIOP block
554                         { $$ = newUNOP($1, 0, $2); }
555         |       UNIOP term
556                         { $$ = newUNOP($1, 0, $2); }
557         |       UNIOPSUB term
558                         { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
559                             append_elem(OP_LIST, $2, scalar($1))); }
560         |       FUNC0
561                         { $$ = newOP($1, 0); }
562         |       FUNC0 '(' ')'
563                         { $$ = newOP($1, 0); }
564         |       FUNC0SUB
565                         { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
566                                 scalar($1)); }
567         |       FUNC1 '(' ')'
568                         { $$ = newOP($1, OPf_SPECIAL); }
569         |       FUNC1 '(' expr ')'
570                         { $$ = newUNOP($1, 0, $3); }
571         |       PMFUNC '(' term ')'
572                         { $$ = pmruntime($1, $3, Nullop); }
573         |       PMFUNC '(' term ',' term ')'
574                         { $$ = pmruntime($1, $3, $5); }
575         |       WORD
576         |       listop
577         ;
578
579 listexpr:       /* NULL */
580                         { $$ = Nullop; }
581         |       argexpr
582                         { $$ = $1; }
583         ;
584
585 listexprcom:    /* NULL */
586                         { $$ = Nullop; }
587         |       expr
588                         { $$ = $1; }
589         |       expr ','
590                         { $$ = $1; }
591         ;
592
593 local   :       LOCAL   { $$ = 0; }
594         |       MY      { $$ = 1; }
595         ;
596
597 my_scalar:      scalar
598                         { in_my = 0; $$ = my($1); }
599         ;
600
601 amper   :       '&' indirob
602                         { $$ = newCVREF($1,$2); }
603         ;
604
605 scalar  :       '$' indirob
606                         { $$ = newSVREF($2); }
607         ;
608
609 ary     :       '@' indirob
610                         { $$ = newAVREF($2); }
611         ;
612
613 hsh     :       '%' indirob
614                         { $$ = newHVREF($2); }
615         ;
616
617 arylen  :       DOLSHARP indirob
618                         { $$ = newAVREF($2); }
619         ;
620
621 star    :       '*' indirob
622                         { $$ = newGVREF(0,$2); }
623         ;
624
625 indirob :       WORD
626                         { $$ = scalar($1); }
627         |       scalar
628                         { $$ = scalar($1);  }
629         |       block
630                         { $$ = scope($1); }
631
632         |       PRIVATEREF
633                         { $$ = $1; }
634         ;
635
636 %% /* PROGRAM */