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