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; |
5f05dabc |
207 | deprecate("while BLOCK BLOCK"); |
208 | $$ = newSTATEOP(0, $1, |
209 | newWHILEOP(0, 1, (LOOP*)Nullop, |
210 | scope($3), $4, $5)); } |
79072805 |
211 | | label UNTIL block block cont |
212 | { copline = $2; |
5f05dabc |
213 | deprecate("until BLOCK BLOCK"); |
214 | $$ = newSTATEOP(0, $1, |
215 | newWHILEOP(0, 1, (LOOP*)Nullop, |
216 | invert(scalar(scope($3))), |
217 | $4, $5)); } |
bbce6d69 |
218 | | label FOR MY remember my_scalar '(' mexpr ')' mblock cont |
36477c24 |
219 | { $$ = block_end($4, |
bbce6d69 |
220 | newFOROP(0, $1, $2, $5, $7, $9, $10)); } |
221 | | label FOR scalar '(' remember mexpr ')' mblock cont |
36477c24 |
222 | { $$ = block_end($5, |
bbce6d69 |
223 | newFOROP(0, $1, $2, mod($3, OP_ENTERLOOP), |
224 | $6, $8, $9)); } |
225 | | label FOR '(' remember mexpr ')' mblock cont |
36477c24 |
226 | { $$ = block_end($4, |
55497cff |
227 | newFOROP(0, $1, $2, Nullop, $5, $7, $8)); } |
bbce6d69 |
228 | | label FOR '(' remember mnexpr ';' mtexpr ';' mnexpr ')' mblock |
8d063cd8 |
229 | /* basically fake up an initialize-while lineseq */ |
55497cff |
230 | { copline = $2; |
36477c24 |
231 | $$ = block_end($4, |
bbce6d69 |
232 | append_elem(OP_LINESEQ, scalar($5), |
233 | newSTATEOP(0, $1, |
234 | newWHILEOP(0, 1, (LOOP*)Nullop, |
235 | scalar($7), |
236 | $11, scalar($9))))); } |
79072805 |
237 | | label block cont /* a block is a loop that happens once */ |
238 | { $$ = newSTATEOP(0, |
463ee0b2 |
239 | $1, newWHILEOP(0, 1, (LOOP*)Nullop, |
240 | Nullop, $2, $3)); } |
8d063cd8 |
241 | ; |
242 | |
243 | nexpr : /* NULL */ |
79072805 |
244 | { $$ = Nullop; } |
8d063cd8 |
245 | | sideff |
246 | ; |
247 | |
248 | texpr : /* NULL means true */ |
79072805 |
249 | { (void)scan_num("1"); $$ = yylval.opval; } |
8d063cd8 |
250 | | expr |
251 | ; |
252 | |
55497cff |
253 | iexpr : expr |
254 | { $$ = invert(scalar($1)); } |
255 | ; |
256 | |
257 | mexpr : expr |
bbce6d69 |
258 | { $$ = $1; intro_my(); } |
259 | ; |
260 | |
261 | mnexpr : nexpr |
262 | { $$ = $1; intro_my(); } |
55497cff |
263 | ; |
264 | |
265 | mtexpr : texpr |
bbce6d69 |
266 | { $$ = $1; intro_my(); } |
55497cff |
267 | ; |
268 | |
269 | miexpr : iexpr |
bbce6d69 |
270 | { $$ = $1; intro_my(); } |
55497cff |
271 | ; |
272 | |
8d063cd8 |
273 | label : /* empty */ |
274 | { $$ = Nullch; } |
32c2e4fb |
275 | | LABEL |
8d063cd8 |
276 | ; |
277 | |
8d063cd8 |
278 | decl : format |
279 | { $$ = 0; } |
280 | | subrout |
281 | { $$ = 0; } |
a687059c |
282 | | package |
283 | { $$ = 0; } |
a0d0e21e |
284 | | use |
85e6fe83 |
285 | { $$ = 0; } |
8d063cd8 |
286 | ; |
287 | |
a0d0e21e |
288 | format : FORMAT startsub WORD block |
289 | { newFORM($2, $3, $4); } |
290 | | FORMAT startsub block |
291 | { newFORM($2, Nullop, $3); } |
8d063cd8 |
292 | ; |
293 | |
4633a7c4 |
294 | subrout : SUB startsub WORD proto block |
295 | { newSUB($2, $3, $4, $5); } |
296 | | SUB startsub WORD proto ';' |
297 | { newSUB($2, $3, $4, Nullop); expect = XSTATE; } |
a0d0e21e |
298 | ; |
299 | |
4633a7c4 |
300 | proto : /* NULL */ |
301 | { $$ = Nullop; } |
302 | | THING |
303 | ; |
304 | |
a0d0e21e |
305 | startsub: /* NULL */ /* start a subroutine scope */ |
306 | { $$ = start_subparse(); } |
8d063cd8 |
307 | ; |
308 | |
a687059c |
309 | package : PACKAGE WORD ';' |
79072805 |
310 | { package($2); } |
93a17b20 |
311 | | PACKAGE ';' |
312 | { package(Nullop); } |
a687059c |
313 | ; |
314 | |
62ac1c99 |
315 | use : USE startsub WORD WORD listexpr ';' |
316 | { utilize($1, $2, $3, $4, $5); } |
85e6fe83 |
317 | ; |
318 | |
a0d0e21e |
319 | expr : expr ANDOP expr |
320 | { $$ = newLOGOP(OP_AND, 0, $1, $3); } |
321 | | expr OROP expr |
322 | { $$ = newLOGOP($2, 0, $1, $3); } |
a0d0e21e |
323 | | argexpr |
324 | ; |
325 | |
326 | argexpr : argexpr ',' |
327 | { $$ = $1; } |
328 | | argexpr ',' term |
79072805 |
329 | { $$ = append_elem(OP_LIST, $1, $3); } |
a0d0e21e |
330 | | term |
8d063cd8 |
331 | ; |
332 | |
a0d0e21e |
333 | listop : LSTOP indirob argexpr |
79072805 |
334 | { $$ = convert($1, OPf_STACKED, |
a0d0e21e |
335 | prepend_elem(OP_LIST, newGVREF($1,$2), $3) ); } |
336 | | FUNC '(' indirob expr ')' |
79072805 |
337 | { $$ = convert($1, OPf_STACKED, |
a0d0e21e |
338 | prepend_elem(OP_LIST, newGVREF($1,$3), $4) ); } |
339 | | term ARROW method '(' listexprcom ')' |
4633a7c4 |
340 | { $$ = convert(OP_ENTERSUB, OPf_STACKED, |
a0d0e21e |
341 | append_elem(OP_LIST, |
55497cff |
342 | prepend_elem(OP_LIST, scalar($1), $5), |
a0d0e21e |
343 | newUNOP(OP_METHOD, 0, $3))); } |
79072805 |
344 | | METHOD indirob listexpr |
4633a7c4 |
345 | { $$ = convert(OP_ENTERSUB, OPf_STACKED, |
a0d0e21e |
346 | append_elem(OP_LIST, |
4633a7c4 |
347 | prepend_elem(OP_LIST, $2, $3), |
a0d0e21e |
348 | newUNOP(OP_METHOD, 0, $1))); } |
349 | | FUNCMETH indirob '(' listexprcom ')' |
4633a7c4 |
350 | { $$ = convert(OP_ENTERSUB, OPf_STACKED, |
a0d0e21e |
351 | append_elem(OP_LIST, |
4633a7c4 |
352 | prepend_elem(OP_LIST, $2, $4), |
a0d0e21e |
353 | newUNOP(OP_METHOD, 0, $1))); } |
79072805 |
354 | | LSTOP listexpr |
355 | { $$ = convert($1, 0, $2); } |
a0d0e21e |
356 | | FUNC '(' listexprcom ')' |
79072805 |
357 | { $$ = convert($1, 0, $3); } |
4633a7c4 |
358 | | LSTOPSUB startsub block listexpr %prec LSTOP |
359 | { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, |
360 | append_elem(OP_LIST, |
361 | prepend_elem(OP_LIST, newANONSUB($2, 0, $3), $4), |
362 | $1)); } |
a687059c |
363 | ; |
364 | |
a0d0e21e |
365 | method : METHOD |
366 | | scalar |
367 | ; |
368 | |
369 | term : term ASSIGNOP term |
370 | { $$ = newASSIGNOP(OPf_STACKED, $1, $2, $3); } |
371 | | term POWOP term |
79072805 |
372 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
373 | | term MULOP term |
79072805 |
374 | { if ($2 != OP_REPEAT) |
375 | scalar($1); |
376 | $$ = newBINOP($2, 0, $1, scalar($3)); } |
a0d0e21e |
377 | | term ADDOP term |
79072805 |
378 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
379 | | term SHIFTOP term |
79072805 |
380 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
381 | | term RELOP term |
79072805 |
382 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
383 | | term EQOP term |
79072805 |
384 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
385 | | term BITANDOP term |
79072805 |
386 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
387 | | term BITOROP term |
79072805 |
388 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
389 | | term DOTDOT term |
79072805 |
390 | { $$ = newRANGE($2, scalar($1), scalar($3));} |
a0d0e21e |
391 | | term ANDAND term |
463ee0b2 |
392 | { $$ = newLOGOP(OP_AND, 0, $1, $3); } |
a0d0e21e |
393 | | term OROR term |
463ee0b2 |
394 | { $$ = newLOGOP(OP_OR, 0, $1, $3); } |
a0d0e21e |
395 | | term '?' term ':' term |
79072805 |
396 | { $$ = newCONDOP(0, $1, $3, $5); } |
a0d0e21e |
397 | | term MATCHOP term |
79072805 |
398 | { $$ = bind_match($2, $1, $3); } |
8d063cd8 |
399 | |
a0d0e21e |
400 | | '-' term %prec UMINUS |
79072805 |
401 | { $$ = newUNOP(OP_NEGATE, 0, scalar($2)); } |
a687059c |
402 | | '+' term %prec UMINUS |
403 | { $$ = $2; } |
8d063cd8 |
404 | | '!' term |
79072805 |
405 | { $$ = newUNOP(OP_NOT, 0, scalar($2)); } |
8d063cd8 |
406 | | '~' term |
79072805 |
407 | { $$ = newUNOP(OP_COMPLEMENT, 0, scalar($2));} |
408 | | REFGEN term |
a0d0e21e |
409 | { $$ = newUNOP(OP_REFGEN, 0, mod($2,OP_REFGEN)); } |
79072805 |
410 | | term POSTINC |
411 | { $$ = newUNOP(OP_POSTINC, 0, |
463ee0b2 |
412 | mod(scalar($1), OP_POSTINC)); } |
79072805 |
413 | | term POSTDEC |
414 | { $$ = newUNOP(OP_POSTDEC, 0, |
463ee0b2 |
415 | mod(scalar($1), OP_POSTDEC)); } |
79072805 |
416 | | PREINC term |
417 | { $$ = newUNOP(OP_PREINC, 0, |
463ee0b2 |
418 | mod(scalar($2), OP_PREINC)); } |
79072805 |
419 | | PREDEC term |
420 | { $$ = newUNOP(OP_PREDEC, 0, |
463ee0b2 |
421 | mod(scalar($2), OP_PREDEC)); } |
55497cff |
422 | | local term %prec UNIOP |
93a17b20 |
423 | { $$ = localize($2,$1); } |
a0d0e21e |
424 | | '(' expr ')' |
79072805 |
425 | { $$ = sawparens($2); } |
8d063cd8 |
426 | | '(' ')' |
8990e307 |
427 | { $$ = sawparens(newNULLLIST()); } |
a0d0e21e |
428 | | '[' expr ']' %prec '(' |
79072805 |
429 | { $$ = newANONLIST($2); } |
430 | | '[' ']' %prec '(' |
431 | { $$ = newANONLIST(Nullop); } |
a0d0e21e |
432 | | HASHBRACK expr ';' '}' %prec '(' |
79072805 |
433 | { $$ = newANONHASH($2); } |
434 | | HASHBRACK ';' '}' %prec '(' |
435 | { $$ = newANONHASH(Nullop); } |
4633a7c4 |
436 | | ANONSUB startsub proto block %prec '(' |
437 | { $$ = newANONSUB($2, $3, $4); } |
79072805 |
438 | | scalar %prec '(' |
8d063cd8 |
439 | { $$ = $1; } |
c07a80fd |
440 | | star '{' expr ';' '}' |
441 | { $$ = newBINOP(OP_GELEM, 0, newGVREF(0,$1), $3); } |
79072805 |
442 | | star %prec '(' |
8d063cd8 |
443 | { $$ = $1; } |
79072805 |
444 | | scalar '[' expr ']' %prec '(' |
445 | { $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3)); } |
446 | | term ARROW '[' expr ']' %prec '(' |
447 | { $$ = newBINOP(OP_AELEM, 0, |
8990e307 |
448 | ref(newAVREF($1),OP_RV2AV), |
79072805 |
449 | scalar($4));} |
463ee0b2 |
450 | | term '[' expr ']' %prec '(' |
a0d0e21e |
451 | { assertref($1); $$ = newBINOP(OP_AELEM, 0, |
8990e307 |
452 | ref(newAVREF($1),OP_RV2AV), |
463ee0b2 |
453 | scalar($3));} |
79072805 |
454 | | hsh %prec '(' |
8d063cd8 |
455 | { $$ = $1; } |
79072805 |
456 | | ary %prec '(' |
8d063cd8 |
457 | { $$ = $1; } |
79072805 |
458 | | arylen %prec '(' |
459 | { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));} |
460 | | scalar '{' expr ';' '}' %prec '(' |
461 | { $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3)); |
462 | expect = XOPERATOR; } |
463 | | term ARROW '{' expr ';' '}' %prec '(' |
464 | { $$ = newBINOP(OP_HELEM, 0, |
8990e307 |
465 | ref(newHVREF($1),OP_RV2HV), |
79072805 |
466 | jmaybe($4)); |
467 | expect = XOPERATOR; } |
463ee0b2 |
468 | | term '{' expr ';' '}' %prec '(' |
a0d0e21e |
469 | { assertref($1); $$ = newBINOP(OP_HELEM, 0, |
8990e307 |
470 | ref(newHVREF($1),OP_RV2HV), |
463ee0b2 |
471 | jmaybe($3)); |
472 | expect = XOPERATOR; } |
a0d0e21e |
473 | | '(' expr ')' '[' expr ']' %prec '(' |
79072805 |
474 | { $$ = newSLICEOP(0, $5, $2); } |
475 | | '(' ')' '[' expr ']' %prec '(' |
476 | { $$ = newSLICEOP(0, $4, Nullop); } |
477 | | ary '[' expr ']' %prec '(' |
478 | { $$ = prepend_elem(OP_ASLICE, |
479 | newOP(OP_PUSHMARK, 0), |
79072805 |
480 | newLISTOP(OP_ASLICE, 0, |
481 | list($3), |
a0d0e21e |
482 | ref($1, OP_ASLICE))); } |
79072805 |
483 | | ary '{' expr ';' '}' %prec '(' |
484 | { $$ = prepend_elem(OP_HSLICE, |
485 | newOP(OP_PUSHMARK, 0), |
79072805 |
486 | newLISTOP(OP_HSLICE, 0, |
487 | list($3), |
a0d0e21e |
488 | ref(oopsHV($1), OP_HSLICE))); |
79072805 |
489 | expect = XOPERATOR; } |
490 | | THING %prec '(' |
491 | { $$ = $1; } |
492 | | amper |
c07a80fd |
493 | { $$ = newUNOP(OP_ENTERSUB, 0, scalar($1)); } |
79072805 |
494 | | amper '(' ')' |
a0d0e21e |
495 | { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); } |
496 | | amper '(' expr ')' |
497 | { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, |
4633a7c4 |
498 | append_elem(OP_LIST, $3, scalar($1))); } |
93a17b20 |
499 | | NOAMP WORD listexpr |
a0d0e21e |
500 | { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, |
a5f75d66 |
501 | append_elem(OP_LIST, $3, scalar($2))); } |
a0d0e21e |
502 | | DO term %prec UNIOP |
463ee0b2 |
503 | { $$ = newUNOP(OP_DOFILE, 0, scalar($2)); } |
79072805 |
504 | | DO block %prec '(' |
505 | { $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); } |
8d063cd8 |
506 | | DO WORD '(' ')' |
c07a80fd |
507 | { $$ = newUNOP(OP_ENTERSUB, |
508 | OPf_SPECIAL|OPf_STACKED, |
4633a7c4 |
509 | prepend_elem(OP_LIST, |
c07a80fd |
510 | scalar(newCVREF( |
511 | (OPpENTERSUB_AMPER<<8), |
512 | scalar($2) |
513 | )),Nullop)); dep();} |
a0d0e21e |
514 | | DO WORD '(' expr ')' |
c07a80fd |
515 | { $$ = newUNOP(OP_ENTERSUB, |
516 | OPf_SPECIAL|OPf_STACKED, |
4633a7c4 |
517 | append_elem(OP_LIST, |
a0d0e21e |
518 | $4, |
c07a80fd |
519 | scalar(newCVREF( |
520 | (OPpENTERSUB_AMPER<<8), |
521 | scalar($2) |
522 | )))); dep();} |
79072805 |
523 | | DO scalar '(' ')' |
a0d0e21e |
524 | { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED, |
4633a7c4 |
525 | prepend_elem(OP_LIST, |
c07a80fd |
526 | scalar(newCVREF(0,scalar($2))), Nullop)); dep();} |
a0d0e21e |
527 | | DO scalar '(' expr ')' |
528 | { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED, |
4633a7c4 |
529 | prepend_elem(OP_LIST, |
a0d0e21e |
530 | $4, |
c07a80fd |
531 | scalar(newCVREF(0,scalar($2))))); dep();} |
8d063cd8 |
532 | | LOOPEX |
85e6fe83 |
533 | { $$ = newOP($1, OPf_SPECIAL); |
534 | hints |= HINT_BLOCK_SCOPE; } |
a0d0e21e |
535 | | LOOPEX term |
8990e307 |
536 | { $$ = newLOOPEX($1,$2); } |
c07a80fd |
537 | | NOTOP argexpr |
538 | { $$ = newUNOP(OP_NOT, 0, scalar($2)); } |
8d063cd8 |
539 | | UNIOP |
79072805 |
540 | { $$ = newOP($1, 0); } |
f0fcb552 |
541 | | UNIOP block |
79072805 |
542 | { $$ = newUNOP($1, 0, $2); } |
a0d0e21e |
543 | | UNIOP term |
79072805 |
544 | { $$ = newUNOP($1, 0, $2); } |
4633a7c4 |
545 | | UNIOPSUB term |
546 | { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, |
547 | append_elem(OP_LIST, $2, scalar($1))); } |
8d063cd8 |
548 | | FUNC0 |
79072805 |
549 | { $$ = newOP($1, 0); } |
ae986130 |
550 | | FUNC0 '(' ')' |
79072805 |
551 | { $$ = newOP($1, 0); } |
4633a7c4 |
552 | | FUNC0SUB |
553 | { $$ = newUNOP(OP_ENTERSUB, 0, |
554 | scalar($1)); } |
03a14243 |
555 | | FUNC1 '(' ')' |
79072805 |
556 | { $$ = newOP($1, OPf_SPECIAL); } |
8d063cd8 |
557 | | FUNC1 '(' expr ')' |
79072805 |
558 | { $$ = newUNOP($1, 0, $3); } |
a0d0e21e |
559 | | PMFUNC '(' term ')' |
79072805 |
560 | { $$ = pmruntime($1, $3, Nullop); } |
a0d0e21e |
561 | | PMFUNC '(' term ',' term ')' |
79072805 |
562 | { $$ = pmruntime($1, $3, $5); } |
563 | | WORD |
378cc40b |
564 | | listop |
8d063cd8 |
565 | ; |
566 | |
79072805 |
567 | listexpr: /* NULL */ |
8990e307 |
568 | { $$ = Nullop; } |
a0d0e21e |
569 | | argexpr |
570 | { $$ = $1; } |
571 | ; |
572 | |
573 | listexprcom: /* NULL */ |
574 | { $$ = Nullop; } |
79072805 |
575 | | expr |
576 | { $$ = $1; } |
a0d0e21e |
577 | | expr ',' |
578 | { $$ = $1; } |
79072805 |
579 | ; |
580 | |
55497cff |
581 | local : LOCAL { $$ = 0; } |
582 | | MY { $$ = 1; } |
583 | ; |
584 | |
585 | my_scalar: scalar |
586 | { in_my = 0; $$ = my($1); } |
587 | ; |
588 | |
79072805 |
589 | amper : '&' indirob |
c07a80fd |
590 | { $$ = newCVREF($1,$2); } |
a687059c |
591 | ; |
592 | |
79072805 |
593 | scalar : '$' indirob |
594 | { $$ = newSVREF($2); } |
a687059c |
595 | ; |
596 | |
79072805 |
597 | ary : '@' indirob |
598 | { $$ = newAVREF($2); } |
599 | ; |
600 | |
601 | hsh : '%' indirob |
602 | { $$ = newHVREF($2); } |
603 | ; |
604 | |
605 | arylen : DOLSHARP indirob |
606 | { $$ = newAVREF($2); } |
607 | ; |
608 | |
609 | star : '*' indirob |
a0d0e21e |
610 | { $$ = newGVREF(0,$2); } |
79072805 |
611 | ; |
612 | |
613 | indirob : WORD |
614 | { $$ = scalar($1); } |
615 | | scalar |
463ee0b2 |
616 | { $$ = scalar($1); } |
79072805 |
617 | | block |
a0d0e21e |
618 | { $$ = scope($1); } |
79072805 |
619 | |
93a17b20 |
620 | | PRIVATEREF |
621 | { $$ = $1; } |
8d063cd8 |
622 | ; |
623 | |
624 | %% /* PROGRAM */ |