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