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