Test case for #10433/#10424.
[p5sagit/p5-mst-13.2.git] / perly.y
CommitLineData
a0d0e21e 1/* perly.y
a687059c 2 *
bc89e66f 3 * Copyright (c) 1991-2001, Larry Wall
a687059c 4 *
9ef589d8 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 8 */
9
10/*
11 * 'I see,' laughed Strider. 'I look foul and feel fair. Is that it?
14a38fd5 12 * All that is gold does not glitter, not all those who wander are lost.'
8d063cd8 13 */
14
15%{
79072805 16#include "EXTERN.h"
864dbfa3 17#define PERL_IN_PERLY_C
8d063cd8 18#include "perl.h"
1e0e26cb 19#ifdef EBCDIC
20#undef YYDEBUG
21#endif
864dbfa3 22#define dep() deprecate("\"do\" to call subroutines")
f0fcb552 23
09bef843 24/* stuff included here to make perly_c.diff apply better */
25
26#define yydebug PL_yydebug
27#define yynerrs PL_yynerrs
28#define yyerrflag PL_yyerrflag
29#define yychar PL_yychar
30#define yyval PL_yyval
31#define yylval PL_yylval
32
33struct ysv {
34 short* yyss;
35 YYSTYPE* yyvs;
36 int oldyydebug;
37 int oldyynerrs;
38 int oldyyerrflag;
39 int oldyychar;
40 YYSTYPE oldyyval;
41 YYSTYPE oldyylval;
42};
43
e1f15930 44static void yydestruct(pTHXo_ void *ptr);
09bef843 45
8d063cd8 46%}
47
48%start prog
49
9d116dd7 50%{
09bef843 51#if 0 /* get this from perly.h instead */
9d116dd7 52%}
53
8d063cd8 54%union {
79072805 55 I32 ival;
56 char *pval;
57 OP *opval;
58 GV *gvval;
8d063cd8 59}
60
9d116dd7 61%{
09bef843 62#endif /* 0 */
a1a0e61e 63
64#ifdef USE_PURE_BISON
65#define YYLEX_PARAM (&yychar)
48cf72c8 66#define yylex yylex_r
a1a0e61e 67#endif
09bef843 68
9d116dd7 69%}
70
fad39ff1 71%token <ival> '{'
f0fcb552 72
a0d0e21e 73%token <opval> WORD METHOD FUNCMETH THING PMFUNC PRIVATEREF
4633a7c4 74%token <opval> FUNC0SUB UNIOPSUB LSTOPSUB
79072805 75%token <pval> LABEL
a0d0e21e 76%token <ival> FORMAT SUB ANONSUB PACKAGE USE
79072805 77%token <ival> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
78%token <ival> LOOPEX DOTDOT
36477c24 79%token <ival> FUNC0 FUNC1 FUNC UNIOP LSTOP
79072805 80%token <ival> RELOP EQOP MULOP ADDOP
55497cff 81%token <ival> DOLSHARP DO HASHBRACK NOAMP
09bef843 82%token <ival> LOCAL MY MYSUB
83%token COLONATTR
79072805 84
09bef843 85%type <ival> prog decl format startsub startanonsub startformsub
28757baa 86%type <ival> remember mremember '&'
bbce6d69 87%type <opval> block mblock lineseq line loop cond else
fad39ff1 88%type <opval> expr term subscripted scalar ary hsh arylen star amper sideff
bbce6d69 89%type <opval> argexpr nexpr texpr iexpr mexpr mnexpr mtexpr miexpr
44a8e56a 90%type <opval> listexpr listexprcom indirob listop method
91%type <opval> formname subname proto subbody cont my_scalar
09bef843 92%type <opval> subattrlist myattrlist mysubrout myattrterm myterm
79072805 93%type <pval> label
79072805 94
fad39ff1 95%nonassoc PREC_LOW
96%nonassoc LOOPEX
97
a0d0e21e 98%left <ival> OROP
463ee0b2 99%left ANDOP
c07a80fd 100%right NOTOP
36477c24 101%nonassoc LSTOP LSTOPSUB
8d063cd8 102%left ','
a0d0e21e 103%right <ival> ASSIGNOP
8d063cd8 104%right '?' ':'
105%nonassoc DOTDOT
106%left OROR
107%left ANDAND
79072805 108%left <ival> BITOROP
109%left <ival> BITANDOP
a687059c 110%nonassoc EQOP
111%nonassoc RELOP
36477c24 112%nonassoc UNIOP UNIOPSUB
79072805 113%left <ival> SHIFTOP
a687059c 114%left ADDOP
115%left MULOP
8990e307 116%left <ival> MATCHOP
79072805 117%right '!' '~' UMINUS REFGEN
118%right <ival> POWOP
119%nonassoc PREINC PREDEC POSTINC POSTDEC
8990e307 120%left ARROW
fad39ff1 121%nonassoc <ival> ')'
8d063cd8 122%left '('
fad39ff1 123%left '[' '{'
8d063cd8 124
125%% /* RULES */
126
ae986130 127prog : /* NULL */
128 {
129#if defined(YYDEBUG) && defined(DEBUGGING)
aea4f609 130 yydebug = (DEBUG_p_TEST);
ae986130 131#endif
c71fccf1 132 PL_expect = XSTATE; $$ = block_start(TRUE);
ae986130 133 }
134 /*CONTINUED*/ lineseq
c71fccf1 135 { newPROG(block_end($1,$2)); }
8d063cd8 136 ;
137
a687059c 138block : '{' remember lineseq '}'
3280af22 139 { if (PL_copline > (line_t)$1)
140 PL_copline = $1;
36477c24 141 $$ = block_end($2, $3); }
a0d0e21e 142 ;
143
55497cff 144remember: /* NULL */ /* start a full lexical scope */
145 { $$ = block_start(TRUE); }
146 ;
147
bbce6d69 148mblock : '{' mremember lineseq '}'
3280af22 149 { if (PL_copline > (line_t)$1)
150 PL_copline = $1;
36477c24 151 $$ = block_end($2, $3); }
55497cff 152 ;
153
154mremember: /* NULL */ /* start a partial lexical scope */
155 { $$ = block_start(FALSE); }
8d063cd8 156 ;
157
158lineseq : /* NULL */
79072805 159 { $$ = Nullop; }
160 | lineseq decl
161 { $$ = $1; }
8d063cd8 162 | lineseq line
463ee0b2 163 { $$ = append_list(OP_LINESEQ,
a0d0e21e 164 (LISTOP*)$1, (LISTOP*)$2);
3280af22 165 PL_pad_reset_pending = TRUE;
166 if ($1 && $2) PL_hints |= HINT_BLOCK_SCOPE; }
8d063cd8 167 ;
168
79072805 169line : label cond
170 { $$ = newSTATEOP(0, $1, $2); }
8d063cd8 171 | loop /* loops add their own labels */
172 | label ';'
173 { if ($1 != Nullch) {
79072805 174 $$ = newSTATEOP(0, $1, newOP(OP_NULL, 0));
450a55e4 175 }
176 else {
79072805 177 $$ = Nullop;
3280af22 178 PL_copline = NOLINE;
32c2e4fb 179 }
3280af22 180 PL_expect = XSTATE; }
8d063cd8 181 | label sideff ';'
79072805 182 { $$ = newSTATEOP(0, $1, $2);
3280af22 183 PL_expect = XSTATE; }
8d063cd8 184 ;
185
a687059c 186sideff : error
79072805 187 { $$ = Nullop; }
a687059c 188 | expr
79072805 189 { $$ = $1; }
a687059c 190 | expr IF expr
79072805 191 { $$ = newLOGOP(OP_AND, 0, $3, $1); }
a687059c 192 | expr UNLESS expr
79072805 193 { $$ = newLOGOP(OP_OR, 0, $3, $1); }
a687059c 194 | expr WHILE expr
8990e307 195 { $$ = newLOOPOP(OPf_PARENS, 1, scalar($3), $1); }
55497cff 196 | expr UNTIL iexpr
197 { $$ = newLOOPOP(OPf_PARENS, 1, $3, $1);}
ecca16b0 198 | expr FOR expr
199 { $$ = newFOROP(0, Nullch, $2,
200 Nullop, $3, $1, Nullop); }
79072805 201 ;
202
203else : /* NULL */
204 { $$ = Nullop; }
55497cff 205 | ELSE mblock
38a230cb 206 { ($2)->op_flags |= OPf_PARENS; $$ = scope($2); }
55497cff 207 | ELSIF '(' mexpr ')' mblock else
3280af22 208 { PL_copline = $1;
2c15bef3 209 $$ = newCONDOP(0, $3, scope($5), $6);
3280af22 210 PL_hints |= HINT_BLOCK_SCOPE; }
79072805 211 ;
212
55497cff 213cond : IF '(' remember mexpr ')' mblock else
3280af22 214 { PL_copline = $1;
36477c24 215 $$ = block_end($3,
bbce6d69 216 newCONDOP(0, $4, scope($6), $7)); }
55497cff 217 | UNLESS '(' remember miexpr ')' mblock else
3280af22 218 { PL_copline = $1;
36477c24 219 $$ = block_end($3,
bbce6d69 220 newCONDOP(0, $4, scope($6), $7)); }
79072805 221 ;
222
223cont : /* NULL */
224 { $$ = Nullop; }
225 | CONTINUE block
226 { $$ = scope($2); }
227 ;
228
55497cff 229loop : label WHILE '(' remember mtexpr ')' mblock cont
3280af22 230 { PL_copline = $2;
36477c24 231 $$ = block_end($4,
55497cff 232 newSTATEOP(0, $1,
bbce6d69 233 newWHILEOP(0, 1, (LOOP*)Nullop,
fb73857a 234 $2, $5, $7, $8))); }
55497cff 235 | label UNTIL '(' remember miexpr ')' mblock cont
3280af22 236 { PL_copline = $2;
36477c24 237 $$ = block_end($4,
55497cff 238 newSTATEOP(0, $1,
bbce6d69 239 newWHILEOP(0, 1, (LOOP*)Nullop,
fb73857a 240 $2, $5, $7, $8))); }
bbce6d69 241 | label FOR MY remember my_scalar '(' mexpr ')' mblock cont
36477c24 242 { $$ = block_end($4,
bbce6d69 243 newFOROP(0, $1, $2, $5, $7, $9, $10)); }
244 | label FOR scalar '(' remember mexpr ')' mblock cont
36477c24 245 { $$ = block_end($5,
bbce6d69 246 newFOROP(0, $1, $2, mod($3, OP_ENTERLOOP),
247 $6, $8, $9)); }
248 | label FOR '(' remember mexpr ')' mblock cont
36477c24 249 { $$ = block_end($4,
55497cff 250 newFOROP(0, $1, $2, Nullop, $5, $7, $8)); }
bbce6d69 251 | label FOR '(' remember mnexpr ';' mtexpr ';' mnexpr ')' mblock
8d063cd8 252 /* basically fake up an initialize-while lineseq */
36c66720 253 { OP *forop;
3280af22 254 PL_copline = $2;
36c66720 255 forop = newSTATEOP(0, $1,
256 newWHILEOP(0, 1, (LOOP*)Nullop,
257 $2, scalar($7),
258 $11, $9));
259 if ($5) {
260 forop = append_elem(OP_LINESEQ,
261 newSTATEOP(0, ($1?savepv($1):Nullch),
262 $5),
263 forop);
264 }
265
266 $$ = block_end($4, forop); }
79072805 267 | label block cont /* a block is a loop that happens once */
fb73857a 268 { $$ = newSTATEOP(0, $1,
269 newWHILEOP(0, 1, (LOOP*)Nullop,
270 NOLINE, Nullop, $2, $3)); }
8d063cd8 271 ;
272
273nexpr : /* NULL */
79072805 274 { $$ = Nullop; }
8d063cd8 275 | sideff
276 ;
277
278texpr : /* NULL means true */
b73d6f50 279 { (void)scan_num("1", &yylval); $$ = yylval.opval; }
8d063cd8 280 | expr
281 ;
282
55497cff 283iexpr : expr
284 { $$ = invert(scalar($1)); }
285 ;
286
287mexpr : expr
bbce6d69 288 { $$ = $1; intro_my(); }
289 ;
290
291mnexpr : nexpr
292 { $$ = $1; intro_my(); }
55497cff 293 ;
294
295mtexpr : texpr
bbce6d69 296 { $$ = $1; intro_my(); }
55497cff 297 ;
298
299miexpr : iexpr
bbce6d69 300 { $$ = $1; intro_my(); }
55497cff 301 ;
302
8d063cd8 303label : /* empty */
304 { $$ = Nullch; }
32c2e4fb 305 | LABEL
8d063cd8 306 ;
307
8d063cd8 308decl : format
309 { $$ = 0; }
310 | subrout
311 { $$ = 0; }
09bef843 312 | mysubrout
313 { $$ = 0; }
a687059c 314 | package
315 { $$ = 0; }
a0d0e21e 316 | use
85e6fe83 317 { $$ = 0; }
8d063cd8 318 ;
319
44a8e56a 320format : FORMAT startformsub formname block
a0d0e21e 321 { newFORM($2, $3, $4); }
44a8e56a 322 ;
323
324formname: WORD { $$ = $1; }
325 | /* NULL */ { $$ = Nullop; }
8d063cd8 326 ;
327
09bef843 328mysubrout: MYSUB startsub subname proto subattrlist subbody
329 { newMYSUB($2, $3, $4, $5, $6); }
330 ;
331
332subrout : SUB startsub subname proto subattrlist subbody
333 { newATTRSUB($2, $3, $4, $5, $6); }
28757baa 334 ;
335
fa83b5b6 336startsub: /* NULL */ /* start a regular subroutine scope */
774d564b 337 { $$ = start_subparse(FALSE, 0); }
28757baa 338 ;
339
340startanonsub: /* NULL */ /* start an anonymous subroutine scope */
774d564b 341 { $$ = start_subparse(FALSE, CVf_ANON); }
28757baa 342 ;
343
44a8e56a 344startformsub: /* NULL */ /* start a format subroutine scope */
774d564b 345 { $$ = start_subparse(TRUE, 0); }
44a8e56a 346 ;
347
2d8e6c8d 348subname : WORD { STRLEN n_a; char *name = SvPV(((SVOP*)$1)->op_sv,n_a);
e858de61 349 if (strEQ(name, "BEGIN") || strEQ(name, "END")
7d30b5c4 350 || strEQ(name, "INIT") || strEQ(name, "CHECK"))
1aff0e91 351 CvSPECIAL_on(PL_compcv);
28757baa 352 $$ = $1; }
a0d0e21e 353 ;
354
4633a7c4 355proto : /* NULL */
356 { $$ = Nullop; }
357 | THING
358 ;
28757baa 359
09bef843 360subattrlist: /* NULL */
361 { $$ = Nullop; }
362 | COLONATTR THING
363 { $$ = $2; }
364 | COLONATTR
365 { $$ = Nullop; }
366 ;
367
368myattrlist: COLONATTR THING
369 { $$ = $2; }
370 | COLONATTR
371 { $$ = Nullop; }
372 ;
373
28757baa 374subbody : block { $$ = $1; }
3280af22 375 | ';' { $$ = Nullop; PL_expect = XSTATE; }
8d063cd8 376 ;
377
a687059c 378package : PACKAGE WORD ';'
79072805 379 { package($2); }
93a17b20 380 | PACKAGE ';'
381 { package(Nullop); }
a687059c 382 ;
383
28757baa 384use : USE startsub
1aff0e91 385 { CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ }
28757baa 386 WORD WORD listexpr ';'
387 { utilize($1, $2, $4, $5, $6); }
85e6fe83 388 ;
389
a0d0e21e 390expr : expr ANDOP expr
391 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
392 | expr OROP expr
393 { $$ = newLOGOP($2, 0, $1, $3); }
fad39ff1 394 | argexpr %prec PREC_LOW
a0d0e21e 395 ;
396
397argexpr : argexpr ','
398 { $$ = $1; }
399 | argexpr ',' term
79072805 400 { $$ = append_elem(OP_LIST, $1, $3); }
fad39ff1 401 | term %prec PREC_LOW
8d063cd8 402 ;
403
a0d0e21e 404listop : LSTOP indirob argexpr
79072805 405 { $$ = convert($1, OPf_STACKED,
a0d0e21e 406 prepend_elem(OP_LIST, newGVREF($1,$2), $3) ); }
407 | FUNC '(' indirob expr ')'
79072805 408 { $$ = convert($1, OPf_STACKED,
a0d0e21e 409 prepend_elem(OP_LIST, newGVREF($1,$3), $4) ); }
410 | term ARROW method '(' listexprcom ')'
4633a7c4 411 { $$ = convert(OP_ENTERSUB, OPf_STACKED,
a0d0e21e 412 append_elem(OP_LIST,
55497cff 413 prepend_elem(OP_LIST, scalar($1), $5),
a0d0e21e 414 newUNOP(OP_METHOD, 0, $3))); }
b1524f17 415 | term ARROW method
416 { $$ = convert(OP_ENTERSUB, OPf_STACKED,
417 append_elem(OP_LIST, scalar($1),
418 newUNOP(OP_METHOD, 0, $3))); }
79072805 419 | METHOD indirob listexpr
4633a7c4 420 { $$ = convert(OP_ENTERSUB, OPf_STACKED,
a0d0e21e 421 append_elem(OP_LIST,
4633a7c4 422 prepend_elem(OP_LIST, $2, $3),
a0d0e21e 423 newUNOP(OP_METHOD, 0, $1))); }
424 | FUNCMETH indirob '(' listexprcom ')'
4633a7c4 425 { $$ = convert(OP_ENTERSUB, OPf_STACKED,
a0d0e21e 426 append_elem(OP_LIST,
4633a7c4 427 prepend_elem(OP_LIST, $2, $4),
a0d0e21e 428 newUNOP(OP_METHOD, 0, $1))); }
79072805 429 | LSTOP listexpr
430 { $$ = convert($1, 0, $2); }
a0d0e21e 431 | FUNC '(' listexprcom ')'
79072805 432 { $$ = convert($1, 0, $3); }
28757baa 433 | LSTOPSUB startanonsub block
09bef843 434 { $3 = newANONATTRSUB($2, 0, Nullop, $3); }
28757baa 435 listexpr %prec LSTOP
4633a7c4 436 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
28757baa 437 append_elem(OP_LIST,
438 prepend_elem(OP_LIST, $3, $5), $1)); }
a687059c 439 ;
440
a0d0e21e 441method : METHOD
442 | scalar
443 ;
444
fad39ff1 445subscripted: star '{' expr ';' '}'
446 { $$ = newBINOP(OP_GELEM, 0, $1, scalar($3)); }
447 | scalar '[' expr ']'
448 { $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3)); }
449 | term ARROW '[' expr ']'
450 { $$ = newBINOP(OP_AELEM, 0,
451 ref(newAVREF($1),OP_RV2AV),
452 scalar($4));}
453 | subscripted '[' expr ']'
454 { $$ = newBINOP(OP_AELEM, 0,
455 ref(newAVREF($1),OP_RV2AV),
456 scalar($3));}
457 | scalar '{' expr ';' '}'
458 { $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
459 PL_expect = XOPERATOR; }
460 | term ARROW '{' expr ';' '}'
461 { $$ = newBINOP(OP_HELEM, 0,
462 ref(newHVREF($1),OP_RV2HV),
463 jmaybe($4));
464 PL_expect = XOPERATOR; }
465 | subscripted '{' expr ';' '}'
466 { $$ = newBINOP(OP_HELEM, 0,
467 ref(newHVREF($1),OP_RV2HV),
468 jmaybe($3));
469 PL_expect = XOPERATOR; }
470 | term ARROW '(' ')'
471 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
472 newCVREF(0, scalar($1))); }
473 | term ARROW '(' expr ')'
474 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
475 append_elem(OP_LIST, $4,
476 newCVREF(0, scalar($1)))); }
477
478 | subscripted '(' expr ')'
479 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
480 append_elem(OP_LIST, $3,
481 newCVREF(0, scalar($1)))); }
482 | subscripted '(' ')'
483 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
484 newCVREF(0, scalar($1))); }
485
486
487
a0d0e21e 488term : term ASSIGNOP term
489 { $$ = newASSIGNOP(OPf_STACKED, $1, $2, $3); }
490 | term POWOP term
79072805 491 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 492 | term MULOP term
79072805 493 { if ($2 != OP_REPEAT)
494 scalar($1);
495 $$ = newBINOP($2, 0, $1, scalar($3)); }
a0d0e21e 496 | term ADDOP term
79072805 497 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 498 | term SHIFTOP term
79072805 499 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 500 | term RELOP term
79072805 501 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 502 | term EQOP term
79072805 503 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 504 | term BITANDOP term
79072805 505 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 506 | term BITOROP term
79072805 507 { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
a0d0e21e 508 | term DOTDOT term
79072805 509 { $$ = newRANGE($2, scalar($1), scalar($3));}
a0d0e21e 510 | term ANDAND term
463ee0b2 511 { $$ = newLOGOP(OP_AND, 0, $1, $3); }
a0d0e21e 512 | term OROR term
463ee0b2 513 { $$ = newLOGOP(OP_OR, 0, $1, $3); }
a0d0e21e 514 | term '?' term ':' term
79072805 515 { $$ = newCONDOP(0, $1, $3, $5); }
a0d0e21e 516 | term MATCHOP term
79072805 517 { $$ = bind_match($2, $1, $3); }
8d063cd8 518
a0d0e21e 519 | '-' term %prec UMINUS
79072805 520 { $$ = newUNOP(OP_NEGATE, 0, scalar($2)); }
a687059c 521 | '+' term %prec UMINUS
522 { $$ = $2; }
8d063cd8 523 | '!' term
79072805 524 { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
8d063cd8 525 | '~' term
79072805 526 { $$ = newUNOP(OP_COMPLEMENT, 0, scalar($2));}
527 | REFGEN term
a0d0e21e 528 { $$ = newUNOP(OP_REFGEN, 0, mod($2,OP_REFGEN)); }
79072805 529 | term POSTINC
530 { $$ = newUNOP(OP_POSTINC, 0,
463ee0b2 531 mod(scalar($1), OP_POSTINC)); }
79072805 532 | term POSTDEC
533 { $$ = newUNOP(OP_POSTDEC, 0,
463ee0b2 534 mod(scalar($1), OP_POSTDEC)); }
79072805 535 | PREINC term
536 { $$ = newUNOP(OP_PREINC, 0,
463ee0b2 537 mod(scalar($2), OP_PREINC)); }
79072805 538 | PREDEC term
539 { $$ = newUNOP(OP_PREDEC, 0,
463ee0b2 540 mod(scalar($2), OP_PREDEC)); }
09bef843 541 | myattrterm %prec UNIOP
542 { $$ = $1; }
543 | LOCAL term %prec UNIOP
93a17b20 544 { $$ = localize($2,$1); }
a0d0e21e 545 | '(' expr ')'
79072805 546 { $$ = sawparens($2); }
8d063cd8 547 | '(' ')'
8990e307 548 { $$ = sawparens(newNULLLIST()); }
fad39ff1 549 | '[' expr ']'
79072805 550 { $$ = newANONLIST($2); }
fad39ff1 551 | '[' ']'
79072805 552 { $$ = newANONLIST(Nullop); }
a0d0e21e 553 | HASHBRACK expr ';' '}' %prec '('
79072805 554 { $$ = newANONHASH($2); }
555 | HASHBRACK ';' '}' %prec '('
556 { $$ = newANONHASH(Nullop); }
09bef843 557 | ANONSUB startanonsub proto subattrlist block %prec '('
558 { $$ = newANONATTRSUB($2, $3, $4, $5); }
79072805 559 | scalar %prec '('
8d063cd8 560 { $$ = $1; }
79072805 561 | star %prec '('
8d063cd8 562 { $$ = $1; }
79072805 563 | hsh %prec '('
8d063cd8 564 { $$ = $1; }
79072805 565 | ary %prec '('
8d063cd8 566 { $$ = $1; }
79072805 567 | arylen %prec '('
568 { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));}
fad39ff1 569 | subscripted
570 { $$ = $1; }
571 | '(' expr ')' '[' expr ']'
79072805 572 { $$ = newSLICEOP(0, $5, $2); }
fad39ff1 573 | '(' ')' '[' expr ']'
79072805 574 { $$ = newSLICEOP(0, $4, Nullop); }
fad39ff1 575 | ary '[' expr ']'
79072805 576 { $$ = prepend_elem(OP_ASLICE,
577 newOP(OP_PUSHMARK, 0),
79072805 578 newLISTOP(OP_ASLICE, 0,
579 list($3),
a0d0e21e 580 ref($1, OP_ASLICE))); }
fad39ff1 581 | ary '{' expr ';' '}'
79072805 582 { $$ = prepend_elem(OP_HSLICE,
583 newOP(OP_PUSHMARK, 0),
79072805 584 newLISTOP(OP_HSLICE, 0,
585 list($3),
a0d0e21e 586 ref(oopsHV($1), OP_HSLICE)));
3280af22 587 PL_expect = XOPERATOR; }
79072805 588 | THING %prec '('
589 { $$ = $1; }
590 | amper
c07a80fd 591 { $$ = newUNOP(OP_ENTERSUB, 0, scalar($1)); }
79072805 592 | amper '(' ')'
a0d0e21e 593 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); }
594 | amper '(' expr ')'
595 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
4633a7c4 596 append_elem(OP_LIST, $3, scalar($1))); }
93a17b20 597 | NOAMP WORD listexpr
a0d0e21e 598 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
a5f75d66 599 append_elem(OP_LIST, $3, scalar($2))); }
a0d0e21e 600 | DO term %prec UNIOP
78ca652e 601 { $$ = dofile($2); }
79072805 602 | DO block %prec '('
603 { $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); }
8d063cd8 604 | DO WORD '(' ')'
c07a80fd 605 { $$ = newUNOP(OP_ENTERSUB,
606 OPf_SPECIAL|OPf_STACKED,
4633a7c4 607 prepend_elem(OP_LIST,
c07a80fd 608 scalar(newCVREF(
609 (OPpENTERSUB_AMPER<<8),
610 scalar($2)
611 )),Nullop)); dep();}
a0d0e21e 612 | DO WORD '(' expr ')'
c07a80fd 613 { $$ = newUNOP(OP_ENTERSUB,
614 OPf_SPECIAL|OPf_STACKED,
4633a7c4 615 append_elem(OP_LIST,
a0d0e21e 616 $4,
c07a80fd 617 scalar(newCVREF(
618 (OPpENTERSUB_AMPER<<8),
619 scalar($2)
620 )))); dep();}
79072805 621 | DO scalar '(' ')'
a0d0e21e 622 { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
4633a7c4 623 prepend_elem(OP_LIST,
c07a80fd 624 scalar(newCVREF(0,scalar($2))), Nullop)); dep();}
a0d0e21e 625 | DO scalar '(' expr ')'
626 { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
4633a7c4 627 prepend_elem(OP_LIST,
a0d0e21e 628 $4,
c07a80fd 629 scalar(newCVREF(0,scalar($2))))); dep();}
8d063cd8 630 | LOOPEX
85e6fe83 631 { $$ = newOP($1, OPf_SPECIAL);
3280af22 632 PL_hints |= HINT_BLOCK_SCOPE; }
a0d0e21e 633 | LOOPEX term
8990e307 634 { $$ = newLOOPEX($1,$2); }
c07a80fd 635 | NOTOP argexpr
636 { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
8d063cd8 637 | UNIOP
79072805 638 { $$ = newOP($1, 0); }
f0fcb552 639 | UNIOP block
79072805 640 { $$ = newUNOP($1, 0, $2); }
a0d0e21e 641 | UNIOP term
79072805 642 { $$ = newUNOP($1, 0, $2); }
4633a7c4 643 | UNIOPSUB term
644 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
645 append_elem(OP_LIST, $2, scalar($1))); }
8d063cd8 646 | FUNC0
79072805 647 { $$ = newOP($1, 0); }
ae986130 648 | FUNC0 '(' ')'
79072805 649 { $$ = newOP($1, 0); }
4633a7c4 650 | FUNC0SUB
28757baa 651 { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
4633a7c4 652 scalar($1)); }
03a14243 653 | FUNC1 '(' ')'
79072805 654 { $$ = newOP($1, OPf_SPECIAL); }
8d063cd8 655 | FUNC1 '(' expr ')'
79072805 656 { $$ = newUNOP($1, 0, $3); }
a0d0e21e 657 | PMFUNC '(' term ')'
79072805 658 { $$ = pmruntime($1, $3, Nullop); }
a0d0e21e 659 | PMFUNC '(' term ',' term ')'
79072805 660 { $$ = pmruntime($1, $3, $5); }
661 | WORD
378cc40b 662 | listop
8d063cd8 663 ;
664
09bef843 665myattrterm: MY myterm myattrlist
666 { $$ = my_attrs($2,$3); }
667 | MY myterm
668 { $$ = localize($2,$1); }
669 ;
670
671myterm : '(' expr ')'
672 { $$ = sawparens($2); }
673 | '(' ')'
674 { $$ = sawparens(newNULLLIST()); }
675 | scalar %prec '('
676 { $$ = $1; }
677 | hsh %prec '('
678 { $$ = $1; }
679 | ary %prec '('
680 { $$ = $1; }
681 ;
682
fad39ff1 683listexpr: /* NULL */ %prec PREC_LOW
8990e307 684 { $$ = Nullop; }
fad39ff1 685 | argexpr %prec PREC_LOW
a0d0e21e 686 { $$ = $1; }
687 ;
688
689listexprcom: /* NULL */
690 { $$ = Nullop; }
79072805 691 | expr
692 { $$ = $1; }
a0d0e21e 693 | expr ','
694 { $$ = $1; }
79072805 695 ;
696
55497cff 697my_scalar: scalar
3280af22 698 { PL_in_my = 0; $$ = my($1); }
55497cff 699 ;
700
79072805 701amper : '&' indirob
c07a80fd 702 { $$ = newCVREF($1,$2); }
a687059c 703 ;
704
79072805 705scalar : '$' indirob
706 { $$ = newSVREF($2); }
a687059c 707 ;
708
79072805 709ary : '@' indirob
710 { $$ = newAVREF($2); }
711 ;
712
713hsh : '%' indirob
714 { $$ = newHVREF($2); }
715 ;
716
717arylen : DOLSHARP indirob
718 { $$ = newAVREF($2); }
719 ;
720
721star : '*' indirob
a0d0e21e 722 { $$ = newGVREF(0,$2); }
79072805 723 ;
724
725indirob : WORD
726 { $$ = scalar($1); }
fad39ff1 727 | scalar %prec PREC_LOW
463ee0b2 728 { $$ = scalar($1); }
79072805 729 | block
a0d0e21e 730 { $$ = scope($1); }
79072805 731
93a17b20 732 | PRIVATEREF
733 { $$ = $1; }
8d063cd8 734 ;
735
736%% /* PROGRAM */
09bef843 737
738/* more stuff added to make perly_c.diff easier to apply */
739
740#ifdef yyparse
741#undef yyparse
742#endif
743#define yyparse() Perl_yyparse(pTHX)
744