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 |
44 | %token <ival> FUNC0 FUNC1 FUNC |
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 |
79072805 |
60 | %nonassoc <ival> LSTOP |
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 |
378cc40b |
71 | %nonassoc <ival> UNIOP |
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 '}' |
a0d0e21e |
96 | { $$ = block_end($1,$2,$3); } |
97 | ; |
98 | |
55497cff |
99 | remember: /* NULL */ /* start a full lexical scope */ |
100 | { $$ = block_start(TRUE); } |
101 | ; |
102 | |
bbce6d69 |
103 | mblock : '{' mremember lineseq '}' |
104 | { $$ = block_end($1,$2,$3); } |
55497cff |
105 | ; |
106 | |
107 | mremember: /* NULL */ /* start a partial lexical scope */ |
108 | { $$ = block_start(FALSE); } |
8d063cd8 |
109 | ; |
110 | |
111 | lineseq : /* NULL */ |
79072805 |
112 | { $$ = Nullop; } |
113 | | lineseq decl |
114 | { $$ = $1; } |
8d063cd8 |
115 | | lineseq line |
463ee0b2 |
116 | { $$ = append_list(OP_LINESEQ, |
a0d0e21e |
117 | (LISTOP*)$1, (LISTOP*)$2); |
118 | pad_reset_pending = TRUE; |
85e6fe83 |
119 | if ($1 && $2) hints |= HINT_BLOCK_SCOPE; } |
8d063cd8 |
120 | ; |
121 | |
79072805 |
122 | line : label cond |
123 | { $$ = newSTATEOP(0, $1, $2); } |
8d063cd8 |
124 | | loop /* loops add their own labels */ |
125 | | label ';' |
126 | { if ($1 != Nullch) { |
79072805 |
127 | $$ = newSTATEOP(0, $1, newOP(OP_NULL, 0)); |
450a55e4 |
128 | } |
129 | else { |
79072805 |
130 | $$ = Nullop; |
131 | copline = NOLINE; |
32c2e4fb |
132 | } |
8990e307 |
133 | expect = XSTATE; } |
8d063cd8 |
134 | | label sideff ';' |
79072805 |
135 | { $$ = newSTATEOP(0, $1, $2); |
8990e307 |
136 | expect = XSTATE; } |
8d063cd8 |
137 | ; |
138 | |
a687059c |
139 | sideff : error |
79072805 |
140 | { $$ = Nullop; } |
a687059c |
141 | | expr |
79072805 |
142 | { $$ = $1; } |
a687059c |
143 | | expr IF expr |
79072805 |
144 | { $$ = newLOGOP(OP_AND, 0, $3, $1); } |
a687059c |
145 | | expr UNLESS expr |
79072805 |
146 | { $$ = newLOGOP(OP_OR, 0, $3, $1); } |
a687059c |
147 | | expr WHILE expr |
8990e307 |
148 | { $$ = newLOOPOP(OPf_PARENS, 1, scalar($3), $1); } |
55497cff |
149 | | expr UNTIL iexpr |
150 | { $$ = newLOOPOP(OPf_PARENS, 1, $3, $1);} |
79072805 |
151 | ; |
152 | |
153 | else : /* NULL */ |
154 | { $$ = Nullop; } |
55497cff |
155 | | ELSE mblock |
79072805 |
156 | { $$ = scope($2); } |
55497cff |
157 | | ELSIF '(' mexpr ')' mblock else |
79072805 |
158 | { copline = $1; |
bbce6d69 |
159 | $$ = newSTATEOP(0, Nullch, |
160 | newCONDOP(0, $3, scope($5), $6)); |
4633a7c4 |
161 | hints |= HINT_BLOCK_SCOPE; } |
79072805 |
162 | ; |
163 | |
55497cff |
164 | cond : IF '(' remember mexpr ')' mblock else |
79072805 |
165 | { copline = $1; |
55497cff |
166 | $$ = block_end($1, $3, |
bbce6d69 |
167 | newCONDOP(0, $4, scope($6), $7)); } |
55497cff |
168 | | UNLESS '(' remember miexpr ')' mblock else |
79072805 |
169 | { copline = $1; |
55497cff |
170 | $$ = block_end($1, $3, |
bbce6d69 |
171 | newCONDOP(0, $4, scope($6), $7)); } |
79072805 |
172 | | IF block block else |
173 | { copline = $1; |
a0d0e21e |
174 | deprecate("if BLOCK BLOCK"); |
79072805 |
175 | $$ = newCONDOP(0, scope($2), scope($3), $4); } |
176 | | UNLESS block block else |
177 | { copline = $1; |
a0d0e21e |
178 | deprecate("unless BLOCK BLOCK"); |
79072805 |
179 | $$ = newCONDOP(0, invert(scalar(scope($2))), |
180 | scope($3), $4); } |
181 | ; |
182 | |
183 | cont : /* NULL */ |
184 | { $$ = Nullop; } |
185 | | CONTINUE block |
186 | { $$ = scope($2); } |
187 | ; |
188 | |
55497cff |
189 | loop : label WHILE '(' remember mtexpr ')' mblock cont |
79072805 |
190 | { copline = $2; |
55497cff |
191 | $$ = block_end($2, $4, |
192 | newSTATEOP(0, $1, |
bbce6d69 |
193 | newWHILEOP(0, 1, (LOOP*)Nullop, |
194 | $5, $7, $8))); } |
55497cff |
195 | | label UNTIL '(' remember miexpr ')' mblock cont |
79072805 |
196 | { copline = $2; |
55497cff |
197 | $$ = block_end($2, $4, |
198 | newSTATEOP(0, $1, |
bbce6d69 |
199 | newWHILEOP(0, 1, (LOOP*)Nullop, |
200 | $5, $7, $8))); } |
79072805 |
201 | | label WHILE block block cont |
202 | { copline = $2; |
bbce6d69 |
203 | $$ = newWHILEOP(0, 1, (LOOP*)Nullop, |
204 | scope($3), $4, $5); } |
79072805 |
205 | | label UNTIL block block cont |
206 | { copline = $2; |
bbce6d69 |
207 | $$ = newWHILEOP(0, 1, (LOOP*)Nullop, |
208 | invert(scalar(scope($3))), |
209 | $4, $5); } |
210 | | label FOR MY remember my_scalar '(' mexpr ')' mblock cont |
55497cff |
211 | { $$ = block_end($2, $4, |
bbce6d69 |
212 | newFOROP(0, $1, $2, $5, $7, $9, $10)); } |
213 | | label FOR scalar '(' remember mexpr ')' mblock cont |
214 | { $$ = block_end($2, $5, |
215 | newFOROP(0, $1, $2, mod($3, OP_ENTERLOOP), |
216 | $6, $8, $9)); } |
217 | | label FOR '(' remember mexpr ')' mblock cont |
55497cff |
218 | { $$ = block_end($2, $4, |
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 */ |
55497cff |
222 | { copline = $2; |
223 | $$ = block_end($2, $4, |
bbce6d69 |
224 | append_elem(OP_LINESEQ, scalar($5), |
225 | newSTATEOP(0, $1, |
226 | newWHILEOP(0, 1, (LOOP*)Nullop, |
227 | scalar($7), |
228 | $11, scalar($9))))); } |
79072805 |
229 | | label block cont /* a block is a loop that happens once */ |
230 | { $$ = newSTATEOP(0, |
463ee0b2 |
231 | $1, newWHILEOP(0, 1, (LOOP*)Nullop, |
232 | 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 | |
a0d0e21e |
280 | format : FORMAT startsub WORD block |
281 | { newFORM($2, $3, $4); } |
282 | | FORMAT startsub block |
283 | { newFORM($2, Nullop, $3); } |
8d063cd8 |
284 | ; |
285 | |
4633a7c4 |
286 | subrout : SUB startsub WORD proto block |
287 | { newSUB($2, $3, $4, $5); } |
288 | | SUB startsub WORD proto ';' |
289 | { newSUB($2, $3, $4, Nullop); expect = XSTATE; } |
a0d0e21e |
290 | ; |
291 | |
4633a7c4 |
292 | proto : /* NULL */ |
293 | { $$ = Nullop; } |
294 | | THING |
295 | ; |
296 | |
a0d0e21e |
297 | startsub: /* NULL */ /* start a subroutine scope */ |
298 | { $$ = start_subparse(); } |
8d063cd8 |
299 | ; |
300 | |
a687059c |
301 | package : PACKAGE WORD ';' |
79072805 |
302 | { package($2); } |
93a17b20 |
303 | | PACKAGE ';' |
304 | { package(Nullop); } |
a687059c |
305 | ; |
306 | |
62ac1c99 |
307 | use : USE startsub WORD WORD listexpr ';' |
308 | { utilize($1, $2, $3, $4, $5); } |
85e6fe83 |
309 | ; |
310 | |
a0d0e21e |
311 | expr : expr ANDOP expr |
312 | { $$ = newLOGOP(OP_AND, 0, $1, $3); } |
313 | | expr OROP expr |
314 | { $$ = newLOGOP($2, 0, $1, $3); } |
a0d0e21e |
315 | | argexpr |
316 | ; |
317 | |
318 | argexpr : argexpr ',' |
319 | { $$ = $1; } |
320 | | argexpr ',' term |
79072805 |
321 | { $$ = append_elem(OP_LIST, $1, $3); } |
a0d0e21e |
322 | | term |
8d063cd8 |
323 | ; |
324 | |
a0d0e21e |
325 | listop : LSTOP indirob argexpr |
79072805 |
326 | { $$ = convert($1, OPf_STACKED, |
a0d0e21e |
327 | prepend_elem(OP_LIST, newGVREF($1,$2), $3) ); } |
328 | | FUNC '(' indirob expr ')' |
79072805 |
329 | { $$ = convert($1, OPf_STACKED, |
a0d0e21e |
330 | prepend_elem(OP_LIST, newGVREF($1,$3), $4) ); } |
331 | | term ARROW method '(' listexprcom ')' |
4633a7c4 |
332 | { $$ = convert(OP_ENTERSUB, OPf_STACKED, |
a0d0e21e |
333 | append_elem(OP_LIST, |
55497cff |
334 | prepend_elem(OP_LIST, scalar($1), $5), |
a0d0e21e |
335 | newUNOP(OP_METHOD, 0, $3))); } |
79072805 |
336 | | METHOD indirob listexpr |
4633a7c4 |
337 | { $$ = convert(OP_ENTERSUB, OPf_STACKED, |
a0d0e21e |
338 | append_elem(OP_LIST, |
4633a7c4 |
339 | prepend_elem(OP_LIST, $2, $3), |
a0d0e21e |
340 | newUNOP(OP_METHOD, 0, $1))); } |
341 | | FUNCMETH indirob '(' listexprcom ')' |
4633a7c4 |
342 | { $$ = convert(OP_ENTERSUB, OPf_STACKED, |
a0d0e21e |
343 | append_elem(OP_LIST, |
4633a7c4 |
344 | prepend_elem(OP_LIST, $2, $4), |
a0d0e21e |
345 | newUNOP(OP_METHOD, 0, $1))); } |
79072805 |
346 | | LSTOP listexpr |
347 | { $$ = convert($1, 0, $2); } |
a0d0e21e |
348 | | FUNC '(' listexprcom ')' |
79072805 |
349 | { $$ = convert($1, 0, $3); } |
4633a7c4 |
350 | | LSTOPSUB startsub block listexpr %prec LSTOP |
351 | { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, |
352 | append_elem(OP_LIST, |
353 | prepend_elem(OP_LIST, newANONSUB($2, 0, $3), $4), |
354 | $1)); } |
a687059c |
355 | ; |
356 | |
a0d0e21e |
357 | method : METHOD |
358 | | scalar |
359 | ; |
360 | |
361 | term : term ASSIGNOP term |
362 | { $$ = newASSIGNOP(OPf_STACKED, $1, $2, $3); } |
363 | | term POWOP term |
79072805 |
364 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
365 | | term MULOP term |
79072805 |
366 | { if ($2 != OP_REPEAT) |
367 | scalar($1); |
368 | $$ = newBINOP($2, 0, $1, scalar($3)); } |
a0d0e21e |
369 | | term ADDOP term |
79072805 |
370 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
371 | | term SHIFTOP term |
79072805 |
372 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
373 | | term RELOP term |
79072805 |
374 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
375 | | term EQOP term |
79072805 |
376 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
377 | | term BITANDOP term |
79072805 |
378 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
379 | | term BITOROP term |
79072805 |
380 | { $$ = newBINOP($2, 0, scalar($1), scalar($3)); } |
a0d0e21e |
381 | | term DOTDOT term |
79072805 |
382 | { $$ = newRANGE($2, scalar($1), scalar($3));} |
a0d0e21e |
383 | | term ANDAND term |
463ee0b2 |
384 | { $$ = newLOGOP(OP_AND, 0, $1, $3); } |
a0d0e21e |
385 | | term OROR term |
463ee0b2 |
386 | { $$ = newLOGOP(OP_OR, 0, $1, $3); } |
a0d0e21e |
387 | | term '?' term ':' term |
79072805 |
388 | { $$ = newCONDOP(0, $1, $3, $5); } |
a0d0e21e |
389 | | term MATCHOP term |
79072805 |
390 | { $$ = bind_match($2, $1, $3); } |
8d063cd8 |
391 | |
a0d0e21e |
392 | | '-' term %prec UMINUS |
79072805 |
393 | { $$ = newUNOP(OP_NEGATE, 0, scalar($2)); } |
a687059c |
394 | | '+' term %prec UMINUS |
395 | { $$ = $2; } |
8d063cd8 |
396 | | '!' term |
79072805 |
397 | { $$ = newUNOP(OP_NOT, 0, scalar($2)); } |
8d063cd8 |
398 | | '~' term |
79072805 |
399 | { $$ = newUNOP(OP_COMPLEMENT, 0, scalar($2));} |
400 | | REFGEN term |
a0d0e21e |
401 | { $$ = newUNOP(OP_REFGEN, 0, mod($2,OP_REFGEN)); } |
79072805 |
402 | | term POSTINC |
403 | { $$ = newUNOP(OP_POSTINC, 0, |
463ee0b2 |
404 | mod(scalar($1), OP_POSTINC)); } |
79072805 |
405 | | term POSTDEC |
406 | { $$ = newUNOP(OP_POSTDEC, 0, |
463ee0b2 |
407 | mod(scalar($1), OP_POSTDEC)); } |
79072805 |
408 | | PREINC term |
409 | { $$ = newUNOP(OP_PREINC, 0, |
463ee0b2 |
410 | mod(scalar($2), OP_PREINC)); } |
79072805 |
411 | | PREDEC term |
412 | { $$ = newUNOP(OP_PREDEC, 0, |
463ee0b2 |
413 | mod(scalar($2), OP_PREDEC)); } |
55497cff |
414 | | local term %prec UNIOP |
93a17b20 |
415 | { $$ = localize($2,$1); } |
a0d0e21e |
416 | | '(' expr ')' |
79072805 |
417 | { $$ = sawparens($2); } |
8d063cd8 |
418 | | '(' ')' |
8990e307 |
419 | { $$ = sawparens(newNULLLIST()); } |
a0d0e21e |
420 | | '[' expr ']' %prec '(' |
79072805 |
421 | { $$ = newANONLIST($2); } |
422 | | '[' ']' %prec '(' |
423 | { $$ = newANONLIST(Nullop); } |
a0d0e21e |
424 | | HASHBRACK expr ';' '}' %prec '(' |
79072805 |
425 | { $$ = newANONHASH($2); } |
426 | | HASHBRACK ';' '}' %prec '(' |
427 | { $$ = newANONHASH(Nullop); } |
4633a7c4 |
428 | | ANONSUB startsub proto block %prec '(' |
429 | { $$ = newANONSUB($2, $3, $4); } |
79072805 |
430 | | scalar %prec '(' |
8d063cd8 |
431 | { $$ = $1; } |
c07a80fd |
432 | | star '{' expr ';' '}' |
433 | { $$ = newBINOP(OP_GELEM, 0, newGVREF(0,$1), $3); } |
79072805 |
434 | | star %prec '(' |
8d063cd8 |
435 | { $$ = $1; } |
79072805 |
436 | | scalar '[' expr ']' %prec '(' |
437 | { $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3)); } |
438 | | term ARROW '[' expr ']' %prec '(' |
439 | { $$ = newBINOP(OP_AELEM, 0, |
8990e307 |
440 | ref(newAVREF($1),OP_RV2AV), |
79072805 |
441 | scalar($4));} |
463ee0b2 |
442 | | term '[' expr ']' %prec '(' |
a0d0e21e |
443 | { assertref($1); $$ = newBINOP(OP_AELEM, 0, |
8990e307 |
444 | ref(newAVREF($1),OP_RV2AV), |
463ee0b2 |
445 | scalar($3));} |
79072805 |
446 | | hsh %prec '(' |
8d063cd8 |
447 | { $$ = $1; } |
79072805 |
448 | | ary %prec '(' |
8d063cd8 |
449 | { $$ = $1; } |
79072805 |
450 | | arylen %prec '(' |
451 | { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));} |
452 | | scalar '{' expr ';' '}' %prec '(' |
453 | { $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3)); |
454 | expect = XOPERATOR; } |
455 | | term ARROW '{' expr ';' '}' %prec '(' |
456 | { $$ = newBINOP(OP_HELEM, 0, |
8990e307 |
457 | ref(newHVREF($1),OP_RV2HV), |
79072805 |
458 | jmaybe($4)); |
459 | expect = XOPERATOR; } |
463ee0b2 |
460 | | term '{' expr ';' '}' %prec '(' |
a0d0e21e |
461 | { assertref($1); $$ = newBINOP(OP_HELEM, 0, |
8990e307 |
462 | ref(newHVREF($1),OP_RV2HV), |
463ee0b2 |
463 | jmaybe($3)); |
464 | expect = XOPERATOR; } |
a0d0e21e |
465 | | '(' expr ')' '[' expr ']' %prec '(' |
79072805 |
466 | { $$ = newSLICEOP(0, $5, $2); } |
467 | | '(' ')' '[' expr ']' %prec '(' |
468 | { $$ = newSLICEOP(0, $4, Nullop); } |
469 | | ary '[' expr ']' %prec '(' |
470 | { $$ = prepend_elem(OP_ASLICE, |
471 | newOP(OP_PUSHMARK, 0), |
79072805 |
472 | newLISTOP(OP_ASLICE, 0, |
473 | list($3), |
a0d0e21e |
474 | ref($1, OP_ASLICE))); } |
79072805 |
475 | | ary '{' expr ';' '}' %prec '(' |
476 | { $$ = prepend_elem(OP_HSLICE, |
477 | newOP(OP_PUSHMARK, 0), |
79072805 |
478 | newLISTOP(OP_HSLICE, 0, |
479 | list($3), |
a0d0e21e |
480 | ref(oopsHV($1), OP_HSLICE))); |
79072805 |
481 | expect = XOPERATOR; } |
482 | | THING %prec '(' |
483 | { $$ = $1; } |
484 | | amper |
c07a80fd |
485 | { $$ = newUNOP(OP_ENTERSUB, 0, scalar($1)); } |
79072805 |
486 | | amper '(' ')' |
a0d0e21e |
487 | { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); } |
488 | | amper '(' expr ')' |
489 | { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, |
4633a7c4 |
490 | append_elem(OP_LIST, $3, scalar($1))); } |
93a17b20 |
491 | | NOAMP WORD listexpr |
a0d0e21e |
492 | { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, |
a5f75d66 |
493 | append_elem(OP_LIST, $3, scalar($2))); } |
a0d0e21e |
494 | | DO term %prec UNIOP |
463ee0b2 |
495 | { $$ = newUNOP(OP_DOFILE, 0, scalar($2)); } |
79072805 |
496 | | DO block %prec '(' |
497 | { $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); } |
8d063cd8 |
498 | | DO WORD '(' ')' |
c07a80fd |
499 | { $$ = newUNOP(OP_ENTERSUB, |
500 | OPf_SPECIAL|OPf_STACKED, |
4633a7c4 |
501 | prepend_elem(OP_LIST, |
c07a80fd |
502 | scalar(newCVREF( |
503 | (OPpENTERSUB_AMPER<<8), |
504 | scalar($2) |
505 | )),Nullop)); dep();} |
a0d0e21e |
506 | | DO WORD '(' expr ')' |
c07a80fd |
507 | { $$ = newUNOP(OP_ENTERSUB, |
508 | OPf_SPECIAL|OPf_STACKED, |
4633a7c4 |
509 | append_elem(OP_LIST, |
a0d0e21e |
510 | $4, |
c07a80fd |
511 | scalar(newCVREF( |
512 | (OPpENTERSUB_AMPER<<8), |
513 | scalar($2) |
514 | )))); dep();} |
79072805 |
515 | | DO scalar '(' ')' |
a0d0e21e |
516 | { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED, |
4633a7c4 |
517 | prepend_elem(OP_LIST, |
c07a80fd |
518 | scalar(newCVREF(0,scalar($2))), Nullop)); dep();} |
a0d0e21e |
519 | | DO scalar '(' expr ')' |
520 | { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED, |
4633a7c4 |
521 | prepend_elem(OP_LIST, |
a0d0e21e |
522 | $4, |
c07a80fd |
523 | scalar(newCVREF(0,scalar($2))))); dep();} |
8d063cd8 |
524 | | LOOPEX |
85e6fe83 |
525 | { $$ = newOP($1, OPf_SPECIAL); |
526 | hints |= HINT_BLOCK_SCOPE; } |
a0d0e21e |
527 | | LOOPEX term |
8990e307 |
528 | { $$ = newLOOPEX($1,$2); } |
c07a80fd |
529 | | NOTOP argexpr |
530 | { $$ = newUNOP(OP_NOT, 0, scalar($2)); } |
8d063cd8 |
531 | | UNIOP |
79072805 |
532 | { $$ = newOP($1, 0); } |
f0fcb552 |
533 | | UNIOP block |
79072805 |
534 | { $$ = newUNOP($1, 0, $2); } |
a0d0e21e |
535 | | UNIOP term |
79072805 |
536 | { $$ = newUNOP($1, 0, $2); } |
4633a7c4 |
537 | | UNIOPSUB term |
538 | { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, |
539 | append_elem(OP_LIST, $2, scalar($1))); } |
8d063cd8 |
540 | | FUNC0 |
79072805 |
541 | { $$ = newOP($1, 0); } |
ae986130 |
542 | | FUNC0 '(' ')' |
79072805 |
543 | { $$ = newOP($1, 0); } |
4633a7c4 |
544 | | FUNC0SUB |
545 | { $$ = newUNOP(OP_ENTERSUB, 0, |
546 | scalar($1)); } |
03a14243 |
547 | | FUNC1 '(' ')' |
79072805 |
548 | { $$ = newOP($1, OPf_SPECIAL); } |
8d063cd8 |
549 | | FUNC1 '(' expr ')' |
79072805 |
550 | { $$ = newUNOP($1, 0, $3); } |
a0d0e21e |
551 | | PMFUNC '(' term ')' |
79072805 |
552 | { $$ = pmruntime($1, $3, Nullop); } |
a0d0e21e |
553 | | PMFUNC '(' term ',' term ')' |
79072805 |
554 | { $$ = pmruntime($1, $3, $5); } |
555 | | WORD |
378cc40b |
556 | | listop |
8d063cd8 |
557 | ; |
558 | |
79072805 |
559 | listexpr: /* NULL */ |
8990e307 |
560 | { $$ = Nullop; } |
a0d0e21e |
561 | | argexpr |
562 | { $$ = $1; } |
563 | ; |
564 | |
565 | listexprcom: /* NULL */ |
566 | { $$ = Nullop; } |
79072805 |
567 | | expr |
568 | { $$ = $1; } |
a0d0e21e |
569 | | expr ',' |
570 | { $$ = $1; } |
79072805 |
571 | ; |
572 | |
55497cff |
573 | local : LOCAL { $$ = 0; } |
574 | | MY { $$ = 1; } |
575 | ; |
576 | |
577 | my_scalar: scalar |
578 | { in_my = 0; $$ = my($1); } |
579 | ; |
580 | |
79072805 |
581 | amper : '&' indirob |
c07a80fd |
582 | { $$ = newCVREF($1,$2); } |
a687059c |
583 | ; |
584 | |
79072805 |
585 | scalar : '$' indirob |
586 | { $$ = newSVREF($2); } |
a687059c |
587 | ; |
588 | |
79072805 |
589 | ary : '@' indirob |
590 | { $$ = newAVREF($2); } |
591 | ; |
592 | |
593 | hsh : '%' indirob |
594 | { $$ = newHVREF($2); } |
595 | ; |
596 | |
597 | arylen : DOLSHARP indirob |
598 | { $$ = newAVREF($2); } |
599 | ; |
600 | |
601 | star : '*' indirob |
a0d0e21e |
602 | { $$ = newGVREF(0,$2); } |
79072805 |
603 | ; |
604 | |
605 | indirob : WORD |
606 | { $$ = scalar($1); } |
607 | | scalar |
463ee0b2 |
608 | { $$ = scalar($1); } |
79072805 |
609 | | block |
a0d0e21e |
610 | { $$ = scope($1); } |
79072805 |
611 | |
93a17b20 |
612 | | PRIVATEREF |
613 | { $$ = $1; } |
8d063cd8 |
614 | ; |
615 | |
616 | %% /* PROGRAM */ |