1 %token NAME INTEGER SC_FLOAT ACCIDENTAL SYMBOL STRING ASCII PRIMITIVENAME CLASSNAME CURRYARG
2 %token VAR ARG CLASSVAR SC_CONST
3 %token NILOBJ TRUEOBJ FALSEOBJ
5 %token ELLIPSIS DOTDOT PIE BEGINCLOSEDFUNC
6 %token BADTOKEN INTERPRET
7 %token BEGINGENERATOR LEFTARROW WHILE
10 %left BINOP KEYBINOP '-' '<' '>' '*' '+' '|' READWRITEVAR
21 #include "PyrParseNode.h"
22 #include "SC_Constants.h"
23 #include "SC_InlineUnaryOp.h"
24 #include "SC_InlineBinaryOp.h"
25 #include "InitAlloc.h"
26 #include "PredefinedSymbols.h"
27 #include "SimpleStack.h"
29 void bcopy(void *src, void *dst, size_t size) ;
31 extern bool compilingCmdLine;
32 extern LongStack generatorStack;
40 { gRootParseNode = (PyrParseNode*)$1; gParserResult = 1; }
42 { gRootParseNode = (PyrParseNode*)$1; gParserResult = 1; }
43 | INTERPRET cmdlinecode
44 { gRootParseNode = (PyrParseNode*)$2; gParserResult = 2; }
49 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$2); }
52 classextensions : classextension
53 | classextensions classextension
54 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$2); }
57 classdef : classname superclass '{' classvardecls methods '}'
58 { $$ = (long)newPyrClassNode((PyrSlotNode*)$1, (PyrSlotNode*)$2,
59 (PyrVarListNode*)$4, (PyrMethodNode*)$5, 0);
61 | classname '[' optname ']' superclass '{' classvardecls methods '}'
62 { $$ = (long)newPyrClassNode((PyrSlotNode*)$1, (PyrSlotNode*)$5,
63 (PyrVarListNode*)$7, (PyrMethodNode*)$8,
68 classextension : '+' classname '{' methods '}'
70 $$ = (long)newPyrClassExtNode((PyrSlotNode*)$2, (PyrMethodNode*)$4);
78 superclass : { $$ = 0; }
83 classvardecls : { $$ = 0; }
84 | classvardecls classvardecl
85 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$2); }
88 classvardecl : CLASSVAR rwslotdeflist ';'
89 { $$ = (long)newPyrVarListNode((PyrVarDefNode*)$2, varClass); }
90 | VAR rwslotdeflist ';'
91 { $$ = (long)newPyrVarListNode((PyrVarDefNode*)$2, varInst); }
92 | SC_CONST constdeflist ';'
93 { $$ = (long)newPyrVarListNode((PyrVarDefNode*)$2, varConst); }
98 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$2); }
101 methoddef : name '{' argdecls funcvardecls primitive methbody '}'
102 { $$ = (long)newPyrMethodNode((PyrSlotNode*)$1, (PyrSlotNode*)$5,
103 (PyrArgListNode*)$3, (PyrVarListNode*)$4, (PyrParseNode*)$6, 0); }
104 | '*' name '{' argdecls funcvardecls primitive methbody '}'
105 { $$ = (long)newPyrMethodNode((PyrSlotNode*)$2, (PyrSlotNode*)$6,
106 (PyrArgListNode*)$4, (PyrVarListNode*)$5, (PyrParseNode*)$7, 1); }
107 | binop '{' argdecls funcvardecls primitive methbody '}'
108 { $$ = (long)newPyrMethodNode((PyrSlotNode*)$1, (PyrSlotNode*)$5,
109 (PyrArgListNode*)$3, (PyrVarListNode*)$4, (PyrParseNode*)$6, 0); }
110 | '*' binop '{' argdecls funcvardecls primitive methbody '}'
111 { $$ = (long)newPyrMethodNode((PyrSlotNode*)$2, (PyrSlotNode*)$6,
112 (PyrArgListNode*)$4, (PyrVarListNode*)$5, (PyrParseNode*)$7, 1); }
129 { $$ = (long)newPyrDropNode((PyrParseNode*)$1, (PyrParseNode*)$2); }
132 cmdlinecode : '(' funcvardecls1 funcbody ')'
133 { $$ = (long)newPyrBlockNode(NULL, (PyrVarListNode*)$2, (PyrParseNode*)$3, false); }
134 | funcvardecls1 funcbody
135 { $$ = (long)newPyrBlockNode(NULL, (PyrVarListNode*)$1, (PyrParseNode*)$2, false); }
137 { $$ = (long)newPyrBlockNode(NULL, NULL, (PyrParseNode*)$1, false); }
142 { $$ = (long)newPyrDropNode((PyrParseNode*)$1, (PyrParseNode*)$2); }
145 primitive : { $$ = 0; }
151 { $$ = (long)newPyrReturnNode(NULL); }
153 { $$ = (long)newPyrReturnNode((PyrParseNode*)$2); }
157 { $$ = (long)newPyrBlockReturnNode(); }
159 { $$ = (long)newPyrReturnNode((PyrParseNode*)$2); }
162 blocklist1 : blocklistitem
163 | blocklist1 blocklistitem
165 $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$2);
169 blocklistitem : blockliteral
173 blocklist : { $$ = 0; }
177 msgsend : name blocklist1
179 $$ = (long)newPyrCallNode((PyrSlotNode*)$1, (PyrParseNode*)$2, 0, 0);
181 | '(' binop2 ')' blocklist1
183 $$ = (long)newPyrCallNode((PyrSlotNode*)$2, (PyrParseNode*)$4, 0, 0);
185 | name '(' ')' blocklist1
187 $$ = (long)newPyrCallNode((PyrSlotNode*)$1, NULL, NULL, (PyrParseNode*)$4);
189 | name '(' arglist1 optkeyarglist ')' blocklist
191 $$ = (long)newPyrCallNode((PyrSlotNode*)$1, (PyrParseNode*)$3,
192 (PyrParseNode*)$4, (PyrParseNode*)$6);
194 | '(' binop2 ')' '(' ')' blocklist1
196 $$ = (long)newPyrCallNode((PyrSlotNode*)$2, NULL, NULL, (PyrParseNode*)$6);
198 | '(' binop2 ')' '(' arglist1 optkeyarglist ')' blocklist
200 $$ = (long)newPyrCallNode((PyrSlotNode*)$2, (PyrParseNode*)$5,
201 (PyrParseNode*)$6, (PyrParseNode*)$8);
203 | name '(' arglistv1 optkeyarglist ')'
205 PyrSlotNode *selectornode;
209 if (isSuperObjNode((PyrParseNode*)$3)) {
210 SetRaw(&((PyrPushNameNode*)$3)->mSlot, s_this);
211 SetSymbol(&slot, s_superPerformList);
213 SetSymbol(&slot, s_performList);
215 selectornode = newPyrSlotNode(&slot);
216 args = linkAfterHead(
218 newPyrPushLitNode((PyrSlotNode*)$1, NULL));
219 $$ = (long)newPyrCallNode(selectornode, args, (PyrParseNode*)$4, 0);
221 | '(' binop2 ')' '(' arglistv1 optkeyarglist ')'
223 PyrSlotNode *selectornode;
227 SetSymbol(&slot, s_performList);
228 selectornode = newPyrSlotNode(&slot);
229 args = linkAfterHead(
231 newPyrPushLitNode((PyrSlotNode*)$2, NULL));
232 $$ = (long)newPyrCallNode(selectornode, args, (PyrParseNode*)$6, 0);
234 | classname '[' arrayelems ']'
235 { $$ = (long)newPyrDynListNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
236 | classname blocklist1
238 PyrSlotNode *selectornode;
242 SetSymbol(&slot, s_new);
243 selectornode = newPyrSlotNode(&slot);
244 args = (PyrParseNode*)newPyrPushNameNode((PyrSlotNode*)$1);
245 $$ = (long)newPyrCallNode(selectornode, args, 0, (PyrParseNode*)$2);
247 | classname '(' ')' blocklist
249 PyrSlotNode *selectornode;
253 SetSymbol(&slot, s_new);
254 selectornode = newPyrSlotNode(&slot);
255 args = (PyrParseNode*)newPyrPushNameNode((PyrSlotNode*)$1);
256 $$ = (long)newPyrCallNode(selectornode, args, NULL, (PyrParseNode*)$4);
258 | classname '(' keyarglist1 ')' blocklist
260 PyrSlotNode *selectornode;
264 SetSymbol(&slot, s_new);
265 selectornode = newPyrSlotNode(&slot);
266 args = (PyrParseNode*)newPyrPushNameNode((PyrSlotNode*)$1);
267 $$ = (long)newPyrCallNode(selectornode, args, (PyrParseNode*)$3, (PyrParseNode*)$5);
269 | classname '(' arglist1 optkeyarglist ')' blocklist
271 PyrSlotNode *selectornode;
275 SetSymbol(&slot, s_new);
276 selectornode = newPyrSlotNode(&slot);
278 (PyrParseNode*)newPyrPushNameNode((PyrSlotNode*)$1),
280 $$ = (long)newPyrCallNode(selectornode, args, (PyrParseNode*)$4, (PyrParseNode*)$6);
282 | classname '(' arglistv1 optkeyarglist ')'
284 PyrSlotNode *selectornode, *selectornode2;
288 if (isSuperObjNode((PyrParseNode*)$1)) {
289 SetRaw(&((PyrPushNameNode*)$1)->mSlot, s_this);
290 SetSymbol(&slot, s_superPerformList);
292 SetSymbol(&slot, s_performList);
294 SetSymbol(&slot2, s_new);
295 selectornode = newPyrSlotNode(&slot);
296 selectornode2 = newPyrSlotNode(&slot2);
298 (PyrParseNode*)newPyrPushNameNode((PyrSlotNode*)$1),
299 newPyrPushLitNode(selectornode2, NULL));
300 args = linkNextNode(args, (PyrParseNode*)$3);
301 $$ = (long)newPyrCallNode(selectornode, args, (PyrParseNode*)$5, 0);
303 | expr '.' '(' ')' blocklist
305 PyrSlotNode *selectornode;
308 SetSymbol(&slot, s_value);
309 selectornode = newPyrSlotNode(&slot);
310 $$ = (long)newPyrCallNode(selectornode, (PyrParseNode*)$1, NULL, (PyrParseNode*)$5);
312 | expr '.' '(' keyarglist1 ')' blocklist
314 PyrSlotNode *selectornode;
317 SetSymbol(&slot, s_value);
318 selectornode = newPyrSlotNode(&slot);
319 $$ = (long)newPyrCallNode(selectornode, (PyrParseNode*)$1, (PyrParseNode*)$4, (PyrParseNode*)$6);
321 | expr '.' name '(' keyarglist1 ')' blocklist
323 $$ = (long)newPyrCallNode((PyrSlotNode*)$3, (PyrParseNode*)$1,
324 (PyrParseNode*)$5, (PyrParseNode*)$7);
326 | expr '.' '(' arglist1 optkeyarglist ')' blocklist
328 PyrSlotNode *selectornode;
332 SetSymbol(&slot, s_value);
333 selectornode = newPyrSlotNode(&slot);
337 $$ = (long)newPyrCallNode(selectornode, args, (PyrParseNode*)$5, (PyrParseNode*)$7);
339 | expr '.' '(' arglistv1 optkeyarglist ')'
341 PyrSlotNode *selectornode;
345 if (isSuperObjNode((PyrParseNode*)$1)) {
346 SetRaw(&((PyrPushNameNode*)$1)->mSlot, s_this);
347 SetSymbol(&slot, s_superPerformList);
349 SetSymbol(&slot, s_performList);
351 SetSymbol(&slot2, s_value);
352 selectornode = newPyrSlotNode(&slot);
355 newPyrPushLitNode(newPyrSlotNode(&slot2), NULL));
356 args = linkNextNode(args, (PyrParseNode*)$4);
357 $$ = (long)newPyrCallNode(selectornode, args, (PyrParseNode*)$5, 0);
359 | expr '.' name '(' ')' blocklist
361 $$ = (long)newPyrCallNode((PyrSlotNode*)$3, (PyrParseNode*)$1, NULL, (PyrParseNode*)$6);
363 | expr '.' name '(' arglist1 optkeyarglist ')' blocklist
366 args = linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$5);
367 $$ = (long)newPyrCallNode((PyrSlotNode*)$3, args, (PyrParseNode*)$6, (PyrParseNode*)$8);
369 | expr '.' name '(' arglistv1 optkeyarglist ')'
371 PyrSlotNode *selectornode;
375 if (isSuperObjNode((PyrParseNode*)$1)) {
376 SetRaw(&((PyrPushNameNode*)$1)->mSlot, s_this);
377 SetSymbol(&slot, s_superPerformList);
379 SetSymbol(&slot, s_performList);
381 selectornode = newPyrSlotNode(&slot);
383 args = linkNextNode((PyrParseNode*)$1, newPyrPushLitNode((PyrSlotNode*)$3, NULL));
384 args = linkNextNode(args, (PyrParseNode*)$5);
385 $$ = (long)newPyrCallNode(selectornode, args, (PyrParseNode*)$6, 0);
387 | expr '.' name blocklist
389 $$ = (long)newPyrCallNode((PyrSlotNode*)$3, (PyrParseNode*)$1, 0, (PyrParseNode*)$4);
393 generator : '{' ':' exprseq { pushls(&generatorStack, $3); pushls(&generatorStack, 1); } ',' qual '}'
396 SetSymbol(&slot, getsym("r"));
397 PyrSlotNode* selectornode = newPyrSlotNode(&slot);
399 PyrParseNode *block = (PyrParseNode*)newPyrBlockNode(0, 0, (PyrParseNode*)$6, false);
400 PyrParseNode *blocklit = (PyrParseNode*)newPyrPushLitNode(NULL, block);
401 $$ = (long)newPyrCallNode(selectornode, (PyrParseNode*)blocklit, 0, 0);
403 | '{' ';' exprseq { pushls(&generatorStack, $3); pushls(&generatorStack, 2); } ',' qual '}'
412 int action = popls(&generatorStack);
413 PyrParseNode* expr = (PyrParseNode*)popls(&generatorStack);
420 SetSymbol(&slot, getsym("yield"));
421 PyrSlotNode* selectornode = newPyrSlotNode(&slot);
423 $$ = (long)newPyrCallNode(selectornode, expr, 0, 0);
435 qual : name LEFTARROW exprseq nextqual
437 // later should check if exprseq is a series and optimize it to for loop
438 PyrParseNode *exprseq = (PyrParseNode*)$3;
439 if (exprseq->mClassno == pn_CallNode) {
440 PyrCallNode *callnode = (PyrCallNode*)exprseq;
441 if (slotRawSymbol(&callnode->mSelector->mSlot) == s_series)
443 SetSymbol(&callnode->mSelector->mSlot, getsym("forSeries"));
445 PyrVarDefNode* var = newPyrVarDefNode((PyrSlotNode*)$1, NULL, 0);
446 PyrArgListNode* args = newPyrArgListNode(var, NULL);
447 PyrParseNode *block = (PyrParseNode*)newPyrBlockNode(args, 0, (PyrParseNode*)$4, false);
448 PyrParseNode *blocklit = (PyrParseNode*)newPyrPushLitNode(NULL, block);
450 callnode->mArglist = linkNextNode(callnode->mArglist, blocklit);
453 } else goto notoptimized1;
457 SetSymbol(&slot, getsym("do"));
458 PyrSlotNode* selectornode = newPyrSlotNode(&slot);
460 PyrVarDefNode* var = newPyrVarDefNode((PyrSlotNode*)$1, NULL, 0);
461 PyrArgListNode* args = newPyrArgListNode(var, NULL);
462 PyrParseNode *block = (PyrParseNode*)newPyrBlockNode(args, 0, (PyrParseNode*)$4, false);
463 PyrParseNode *blocklit = (PyrParseNode*)newPyrPushLitNode(NULL, block);
465 PyrParseNode* args2 = linkNextNode(exprseq, blocklit);
466 $$ = (long)newPyrCallNode(selectornode, args2, 0, 0);
469 | name name LEFTARROW exprseq nextqual
471 // later should check if exprseq is a series and optimize it to for loop
472 PyrParseNode *exprseq = (PyrParseNode*)$4;
473 if (exprseq->mClassno == pn_CallNode) {
474 PyrCallNode *callnode = (PyrCallNode*)exprseq;
475 if (slotRawSymbol(&callnode->mSelector->mSlot) == s_series)
477 SetSymbol(&callnode->mSelector->mSlot, getsym("forSeries"));
479 PyrVarDefNode* var1 = newPyrVarDefNode((PyrSlotNode*)$1, NULL, 0);
480 PyrVarDefNode* var2 = newPyrVarDefNode((PyrSlotNode*)$2, NULL, 0);
481 PyrVarDefNode* vars = (PyrVarDefNode*)linkNextNode(var1, var2);
482 PyrArgListNode* args = newPyrArgListNode(vars, NULL);
483 PyrParseNode *block = (PyrParseNode*)newPyrBlockNode(args, 0, (PyrParseNode*)$5, false);
484 PyrParseNode *blocklit = (PyrParseNode*)newPyrPushLitNode(NULL, block);
486 callnode->mArglist = linkNextNode(callnode->mArglist, blocklit);
489 } else goto notoptimized2;
493 SetSymbol(&slot, getsym("do"));
494 PyrSlotNode* selectornode = newPyrSlotNode(&slot);
496 PyrVarDefNode* var1 = newPyrVarDefNode((PyrSlotNode*)$1, NULL, 0);
497 PyrVarDefNode* var2 = newPyrVarDefNode((PyrSlotNode*)$2, NULL, 0);
498 PyrVarDefNode* vars = (PyrVarDefNode*)linkNextNode(var1, var2);
499 PyrArgListNode* args = newPyrArgListNode(vars, NULL);
500 PyrParseNode *block = (PyrParseNode*)newPyrBlockNode(args, 0, (PyrParseNode*)$5, false);
501 PyrParseNode *blocklit = (PyrParseNode*)newPyrPushLitNode(NULL, block);
503 PyrParseNode* args2 = linkNextNode(exprseq, blocklit);
504 $$ = (long)newPyrCallNode(selectornode, args2, 0, 0);
507 | VAR name '=' exprseq nextqual
510 SetSymbol(&slot, s_value);
511 PyrSlotNode* selectornode = newPyrSlotNode(&slot);
513 PyrVarDefNode* var = newPyrVarDefNode((PyrSlotNode*)$2, NULL, 0);
514 PyrArgListNode* args = newPyrArgListNode(var, NULL);
515 PyrParseNode *block = (PyrParseNode*)newPyrBlockNode(args, 0, (PyrParseNode*)$5, false);
516 PyrParseNode *blocklit = (PyrParseNode*)newPyrPushLitNode(NULL, block);
517 PyrParseNode* args2 = (PyrParseNode*)linkNextNode(blocklit, (PyrParseNode*)$4);
519 $$ = (long)newPyrCallNode(selectornode, args2, 0, 0);
524 SetSymbol(&slot, getsym("if"));
525 PyrSlotNode* selectornode = newPyrSlotNode(&slot);
526 PyrParseNode *block = (PyrParseNode*)newPyrBlockNode(0, 0, (PyrParseNode*)$2, false);
527 PyrParseNode *blocklit = (PyrParseNode*)newPyrPushLitNode(NULL, block);
528 PyrParseNode* args2 = (PyrParseNode*)linkNextNode((PyrParseNode*)$1, blocklit);
530 $$ = (long)newPyrCallNode(selectornode, args2, 0, 0);
532 | ':' ':' exprseq nextqual
534 $$ = (long)newPyrDropNode((PyrParseNode*)$3, (PyrParseNode*)$4);
536 | ':' WHILE exprseq nextqual
539 SetSymbol(&slot, getsym("alwaysYield"));
540 PyrSlotNode* selectornode1 = newPyrSlotNode(&slot);
542 SetSymbol(&slot, getsym("if"));
543 PyrSlotNode* selectornode2 = newPyrSlotNode(&slot);
546 PyrParseNode *pushnil = (PyrParseNode*)newPyrPushLitNode(newPyrSlotNode(&slot), NULL);
548 PyrParseNode *yieldNil = (PyrParseNode*)newPyrCallNode(selectornode1, pushnil, 0, 0);
550 PyrParseNode *block1 = (PyrParseNode*)newPyrBlockNode(0, 0, yieldNil, false);
551 PyrParseNode *blocklit1 = (PyrParseNode*)newPyrPushLitNode(NULL, block1);
552 PyrParseNode *block2 = (PyrParseNode*)newPyrBlockNode(0, 0, (PyrParseNode*)$4, false);
553 PyrParseNode *blocklit2 = (PyrParseNode*)newPyrPushLitNode(NULL, block2);
554 PyrParseNode* args2 = (PyrParseNode*)linkNextNode((PyrParseNode*)$3, blocklit2);
555 PyrParseNode* args3 = (PyrParseNode*)linkNextNode(args2, blocklit1);
557 $$ = (long)newPyrCallNode(selectornode2, args3, 0, 0);
569 PyrParseNode* node = (PyrParseNode*)$2;
575 PyrParseNode* argnode;
576 PyrSlotNode* selectornode;
578 argnode = (PyrParseNode*)newPyrPushLitNode((PyrSlotNode*)$2, NULL);
579 SetSymbol(&slot, s_envirGet);
580 selectornode = newPyrSlotNode(&slot);
581 $$ = (long)newPyrCallNode(selectornode, argnode, 0, 0);
584 { $$ = (long)newPyrDynListNode(0, (PyrParseNode*)$2); }
587 | '(' ':' valrange3 ')'
589 | '(' dictslotlist ')'
590 { $$ = (long)newPyrDynDictNode((PyrParseNode*)$2); }
592 { $$ = (long)newPyrPushNameNode((PyrSlotNode*)$1); }
593 | expr1 '[' arglist1 ']'
595 PyrSlotNode *selectornode;
599 SetSymbol(&slot, s_at);
600 selectornode = newPyrSlotNode(&slot);
604 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
609 valrangex1 : expr1 '[' arglist1 DOTDOT ']'
611 PyrSlotNode *selectornode;
612 PyrPushLitNode *nilnode1, *nilnode2;
613 PyrSlot selectorSlot, nilSlot;
616 int arglen = nodeListLength((PyrParseNode*)$3);
618 error("ArrayedCollection subrange has too many arguments.\n");
619 nodePostErrorLine((PyrParseNode*)$3);
624 nilnode2 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
626 SetSymbol(&selectorSlot, s_copyseries);
627 selectornode = newPyrSlotNode(&selectorSlot);
628 args = linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3);
630 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
631 args = linkNextNode(args, nilnode1);
633 args = linkNextNode(args, nilnode2);
634 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
636 | expr1 '[' DOTDOT exprseq ']'
638 PyrSlotNode *selectornode;
639 PyrPushLitNode *nilnode1, *nilnode2;
640 PyrSlot selectorSlot, nilSlot;
644 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
645 nilnode2 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
647 SetSymbol(&selectorSlot, s_copyseries);
648 selectornode = newPyrSlotNode(&selectorSlot);
649 args = linkNextNode((PyrParseNode*)$1, nilnode1);
650 args = linkNextNode(args, nilnode2);
651 args = linkNextNode(args, (PyrParseNode*)$4);
652 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
654 | expr1 '[' arglist1 DOTDOT exprseq ']'
656 PyrSlotNode *selectornode;
657 PyrPushLitNode *nilnode1;
658 PyrSlot selectorSlot, nilSlot;
661 int arglen = nodeListLength((PyrParseNode*)$3);
663 error("ArrayedCollection subrange has too many arguments.\n");
664 nodePostErrorLine((PyrParseNode*)$3);
668 SetSymbol(&selectorSlot, s_copyseries);
669 selectornode = newPyrSlotNode(&selectorSlot);
670 args = linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3);
673 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
674 args = linkNextNode(args, nilnode1);
676 args = linkNextNode(args, (PyrParseNode*)$5);
677 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
681 valrangeassign : expr1 '[' arglist1 DOTDOT ']' '=' expr
683 PyrSlotNode *selectornode;
684 PyrPushLitNode *nilnode1, *nilnode2;
685 PyrSlot selectorSlot, nilSlot;
688 int arglen = nodeListLength((PyrParseNode*)$3);
690 error("ArrayedCollection subrange has too many arguments.\n");
691 nodePostErrorLine((PyrParseNode*)$3);
696 nilnode2 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
698 SetSymbol(&selectorSlot, s_putseries);
699 selectornode = newPyrSlotNode(&selectorSlot);
700 args = linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3);
702 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
703 args = linkNextNode(args, nilnode1);
705 args = linkNextNode(args, nilnode2);
706 args = linkNextNode(args, (PyrParseNode*)$7);
707 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
709 | expr1 '[' DOTDOT exprseq ']' '=' expr
711 PyrSlotNode *selectornode;
712 PyrPushLitNode *nilnode1, *nilnode2;
713 PyrSlot selectorSlot, nilSlot;
717 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
718 nilnode2 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
720 SetSymbol(&selectorSlot, s_putseries);
721 selectornode = newPyrSlotNode(&selectorSlot);
722 args = linkNextNode((PyrParseNode*)$1, nilnode1);
723 args = linkNextNode(args, nilnode2);
724 args = linkNextNode(args, (PyrParseNode*)$4);
725 args = linkNextNode(args, (PyrParseNode*)$7);
726 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
728 | expr1 '[' arglist1 DOTDOT exprseq ']' '=' expr
730 PyrSlotNode *selectornode;
731 PyrPushLitNode *nilnode1;
732 PyrSlot selectorSlot, nilSlot;
735 int arglen = nodeListLength((PyrParseNode*)$3);
737 error("ArrayedCollection subrange has too many arguments.\n");
738 nodePostErrorLine((PyrParseNode*)$3);
742 SetSymbol(&selectorSlot, s_putseries);
743 selectornode = newPyrSlotNode(&selectorSlot);
744 args = linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3);
747 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
748 args = linkNextNode(args, nilnode1);
750 args = linkNextNode(args, (PyrParseNode*)$5);
751 args = linkNextNode(args, (PyrParseNode*)$8);
752 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
756 valrangexd : expr '.' '[' arglist1 DOTDOT ']'
758 PyrSlotNode *selectornode;
759 PyrPushLitNode *nilnode1, *nilnode2;
760 PyrSlot selectorSlot, nilSlot;
763 int arglen = nodeListLength((PyrParseNode*)$4);
765 error("ArrayedCollection subrange has too many arguments.\n");
766 nodePostErrorLine((PyrParseNode*)$3);
771 nilnode2 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
773 SetSymbol(&selectorSlot, s_copyseries);
774 selectornode = newPyrSlotNode(&selectorSlot);
775 args = linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$4);
777 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
778 args = linkNextNode(args, nilnode1);
780 args = linkNextNode(args, nilnode2);
781 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
783 | expr '.' '[' DOTDOT exprseq ']'
785 PyrSlotNode *selectornode;
786 PyrPushLitNode *nilnode1, *nilnode2;
787 PyrSlot selectorSlot, nilSlot;
791 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
792 nilnode2 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
794 SetSymbol(&selectorSlot, s_copyseries);
795 selectornode = newPyrSlotNode(&selectorSlot);
796 args = linkNextNode((PyrParseNode*)$1, nilnode1);
797 args = linkNextNode(args, nilnode2);
798 args = linkNextNode(args, (PyrParseNode*)$5);
799 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
801 | expr '.' '[' arglist1 DOTDOT exprseq ']'
803 PyrSlotNode *selectornode;
804 PyrPushLitNode *nilnode1;
805 PyrSlot selectorSlot, nilSlot;
808 int arglen = nodeListLength((PyrParseNode*)$4);
810 error("ArrayedCollection subrange has too many arguments.\n");
811 nodePostErrorLine((PyrParseNode*)$3);
815 SetSymbol(&selectorSlot, s_copyseries);
816 selectornode = newPyrSlotNode(&selectorSlot);
817 args = linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$4);
820 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
821 args = linkNextNode(args, nilnode1);
823 args = linkNextNode(args, (PyrParseNode*)$6);
824 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
826 | expr '.' '[' arglist1 DOTDOT ']' '=' expr
828 PyrSlotNode *selectornode;
829 PyrPushLitNode *nilnode1, *nilnode2;
830 PyrSlot selectorSlot, nilSlot;
833 int arglen = nodeListLength((PyrParseNode*)$4);
835 error("ArrayedCollection subrange has too many arguments.\n");
836 nodePostErrorLine((PyrParseNode*)$3);
841 nilnode2 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
843 SetSymbol(&selectorSlot, s_putseries);
844 selectornode = newPyrSlotNode(&selectorSlot);
845 args = linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$4);
847 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
848 args = linkNextNode(args, nilnode1);
850 args = linkNextNode(args, nilnode2);
851 args = linkNextNode(args, (PyrParseNode*)$8);
852 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
854 | expr '.' '[' DOTDOT exprseq ']' '=' expr
856 PyrSlotNode *selectornode;
857 PyrPushLitNode *nilnode1, *nilnode2;
858 PyrSlot selectorSlot, nilSlot;
862 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
863 nilnode2 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
865 SetSymbol(&selectorSlot, s_putseries);
866 selectornode = newPyrSlotNode(&selectorSlot);
867 args = linkNextNode((PyrParseNode*)$1, nilnode1);
868 args = linkNextNode(args, nilnode2);
869 args = linkNextNode(args, (PyrParseNode*)$5);
870 args = linkNextNode(args, (PyrParseNode*)$8);
871 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
873 | expr '.' '[' arglist1 DOTDOT exprseq ']' '=' expr
875 PyrSlotNode *selectornode;
876 PyrPushLitNode *nilnode1;
877 PyrSlot selectorSlot, nilSlot;
880 int arglen = nodeListLength((PyrParseNode*)$4);
882 error("ArrayedCollection subrange has too many arguments.\n");
883 nodePostErrorLine((PyrParseNode*)$3);
887 SetSymbol(&selectorSlot, s_putseries);
888 selectornode = newPyrSlotNode(&selectorSlot);
889 args = linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$4);
892 nilnode1 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
893 args = linkNextNode(args, nilnode1);
895 args = linkNextNode(args, (PyrParseNode*)$6);
896 args = linkNextNode(args, (PyrParseNode*)$9);
897 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
901 valrange2 : exprseq DOTDOT
903 // if this is not used in a 'do' or list comprehension, then should return an error.
904 PyrSlotNode *selectornode;
905 PyrPushLitNode *nilnode, *nilnode2;
906 PyrSlot selectorSlot, nilSlot;
910 nilnode = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
911 nilnode2 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
913 SetSymbol(&selectorSlot, s_series);
914 selectornode = newPyrSlotNode(&selectorSlot);
915 args = linkNextNode((PyrParseNode*)$1, nilnode);
916 args = linkNextNode(args, nilnode2);
917 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
922 PyrSlotNode *selectornode;
923 PyrPushLitNode *nilnode, *zeronode;
924 PyrSlot selectorSlot, nilSlot, zeroSlot;
927 SetInt(&zeroSlot, 0);
929 nilnode = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
930 zeronode = newPyrPushLitNode(newPyrSlotNode(&zeroSlot), NULL);
932 SetSymbol(&selectorSlot, s_series);
933 selectornode = newPyrSlotNode(&selectorSlot);
934 args = linkNextNode(zeronode, nilnode);
935 args = linkNextNode(args, (PyrParseNode*)$2);
936 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
939 | exprseq DOTDOT exprseq
941 PyrSlotNode *selectornode;
942 PyrPushLitNode *nilnode;
943 PyrSlot selectorSlot, nilSlot;
947 nilnode = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
949 SetSymbol(&selectorSlot, s_series);
950 selectornode = newPyrSlotNode(&selectorSlot);
951 args = linkNextNode((PyrParseNode*)$1, nilnode);
952 args = linkNextNode(args, (PyrParseNode*)$3);
953 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
956 | exprseq ',' exprseq DOTDOT exprseq
958 PyrSlotNode *selectornode;
959 PyrSlot selectorSlot;
962 SetSymbol(&selectorSlot, s_series);
963 selectornode = newPyrSlotNode(&selectorSlot);
967 args = linkNextNode(args, (PyrParseNode*)$5);
968 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
970 | exprseq ',' exprseq DOTDOT
972 // if this is not used in a 'do' or list comprehension, then should return an error.
973 PyrSlotNode *selectornode;
974 PyrSlot selectorSlot, nilSlot;
976 PyrPushLitNode *nilnode;
979 nilnode = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
981 SetSymbol(&selectorSlot, s_series);
982 selectornode = newPyrSlotNode(&selectorSlot);
986 args = linkNextNode(args, nilnode);
987 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
991 valrange3 : DOTDOT exprseq
993 PyrSlotNode *selectornode;
994 PyrPushLitNode *nilnode, *zeronode;
995 PyrSlot selectorSlot, nilSlot, zeroSlot;
998 SetInt(&zeroSlot, 0);
1000 nilnode = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
1001 zeronode = newPyrPushLitNode(newPyrSlotNode(&zeroSlot), NULL);
1003 SetSymbol(&selectorSlot, getsym("seriesIter"));
1004 selectornode = newPyrSlotNode(&selectorSlot);
1005 args = linkNextNode(zeronode, nilnode);
1006 args = linkNextNode(args, (PyrParseNode*)$2);
1007 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
1012 PyrSlotNode *selectornode;
1013 PyrPushLitNode *nilnode, *nilnode2;
1014 PyrSlot selectorSlot, nilSlot;
1018 nilnode = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
1019 nilnode2 = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
1021 SetSymbol(&selectorSlot, getsym("seriesIter"));
1022 selectornode = newPyrSlotNode(&selectorSlot);
1023 args = linkNextNode((PyrParseNode*)$1, nilnode);
1024 args = linkNextNode(args, nilnode2);
1025 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
1028 | exprseq DOTDOT exprseq
1030 PyrSlotNode *selectornode;
1031 PyrPushLitNode *nilnode;
1032 PyrSlot selectorSlot, nilSlot;
1036 nilnode = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
1038 SetSymbol(&selectorSlot, getsym("seriesIter"));
1039 selectornode = newPyrSlotNode(&selectorSlot);
1040 args = linkNextNode((PyrParseNode*)$1, nilnode);
1041 args = linkNextNode(args, (PyrParseNode*)$3);
1042 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
1045 | exprseq ',' exprseq DOTDOT
1047 PyrSlotNode *selectornode;
1048 PyrPushLitNode *nilnode;
1049 PyrSlot selectorSlot, nilSlot;
1053 nilnode = newPyrPushLitNode(newPyrSlotNode(&nilSlot), NULL);
1055 SetSymbol(&selectorSlot, getsym("seriesIter"));
1056 selectornode = newPyrSlotNode(&selectorSlot);
1057 args = linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3);
1058 args = linkNextNode(args, nilnode);
1059 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
1061 | exprseq ',' exprseq DOTDOT exprseq
1063 PyrSlotNode *selectornode;
1064 PyrSlot selectorSlot;
1067 SetSymbol(&selectorSlot, getsym("seriesIter"));
1068 selectornode = newPyrSlotNode(&selectorSlot);
1069 args = linkNextNode(
1072 args = linkNextNode(args, (PyrParseNode*)$5);
1073 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
1080 | classname { $$ = (long)newPyrPushNameNode((PyrSlotNode*)$1); }
1081 | expr '.' '[' arglist1 ']'
1083 PyrSlotNode *selectornode;
1087 SetSymbol(&slot, s_at);
1088 selectornode = newPyrSlotNode(&slot);
1089 args = linkNextNode(
1092 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
1096 PyrParseNode *node, *args;
1097 PyrSlotNode *slotnode;
1100 SetSymbol(&slot, s_ref);
1101 slotnode = newPyrSlotNode(&slot);
1102 node = (PyrParseNode*)newPyrPushNameNode(slotnode);
1103 args = linkNextNode(node, (PyrParseNode*)$2);
1104 SetSymbol(&slot, s_new);
1105 slotnode = newPyrSlotNode(&slot);
1106 $$ = (long)newPyrCallNode(slotnode, args, 0, 0);
1108 | expr binop2 adverb expr %prec BINOP
1110 $$ = (long)newPyrBinopCallNode((PyrSlotNode*)$2,
1111 (PyrParseNode*)$1, (PyrParseNode*)$4, (PyrParseNode*)$3);
1115 $$ = (long)newPyrAssignNode((PyrSlotNode*)$1, (PyrParseNode*)$3, 0);
1119 PyrParseNode *argnode, *args;
1120 PyrSlotNode* selectornode;
1122 argnode = (PyrParseNode*)newPyrPushLitNode((PyrSlotNode*)$2, NULL);
1123 args = linkNextNode(argnode, (PyrParseNode*)$4);
1124 SetSymbol(&slot, s_envirPut);
1125 selectornode = newPyrSlotNode(&slot);
1126 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
1128 | expr '.' name '=' expr
1130 $$ = (long)newPyrSetterNode((PyrSlotNode*)$3,
1131 (PyrParseNode*)$1, (PyrParseNode*)$5);
1133 | name '(' arglist1 optkeyarglist ')' '=' expr
1136 error("Setter method called with keyword arguments.\n");
1137 nodePostErrorLine((PyrParseNode*)$4);
1140 $$ = (long)newPyrSetterNode((PyrSlotNode*)$1,
1141 (PyrParseNode*)$3, (PyrParseNode*)$7);
1143 | '#' mavars '=' expr
1145 $$ = (long)newPyrMultiAssignNode((PyrMultiAssignVarListNode*)$2,
1146 (PyrParseNode*)$4, 0);
1148 | expr1 '[' arglist1 ']' '=' expr
1150 PyrSlotNode *selectornode;
1154 SetSymbol(&slot, s_put);
1155 selectornode = newPyrSlotNode(&slot);
1156 args = linkNextNode(
1159 args = linkNextNode( args, (PyrParseNode*)$6);
1160 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
1162 | expr '.' '[' arglist1 ']' '=' expr
1164 PyrSlotNode *selectornode;
1168 SetSymbol(&slot, s_put);
1169 selectornode = newPyrSlotNode(&slot);
1170 args = linkNextNode(
1173 args = linkNextNode( args, (PyrParseNode*)$7);
1174 $$ = (long)newPyrCallNode(selectornode, args, 0, 0);
1178 adverb : { $$ = 0; }
1179 | '.' name { $$ = (long)newPyrPushLitNode((PyrSlotNode*)$2, NULL); }
1180 | '.' integer { $$ = (long)newPyrPushLitNode((PyrSlotNode*)$2, NULL); }
1181 | '.' '(' exprseq ')' { $$ = $3; }
1187 $$ = (long)newPyrDropNode((PyrParseNode*)$1, (PyrParseNode*)$3);
1191 exprseq : exprn optsemi
1194 arrayelems : { $$ = 0; }
1195 | arrayelems1 optcomma
1199 arrayelems1 : exprseq
1200 | exprseq ':' exprseq
1201 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1204 PyrParseNode* key = newPyrPushLitNode((PyrSlotNode*)$1, NULL);
1205 $$ = (long)linkNextNode(key, (PyrParseNode*)$2);
1207 | arrayelems1 ',' exprseq
1208 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1209 | arrayelems1 ',' keybinop exprseq
1211 PyrParseNode* elems;
1212 PyrParseNode* key = newPyrPushLitNode((PyrSlotNode*)$3, NULL);
1213 elems = (PyrParseNode*)linkNextNode(key, (PyrParseNode*)$4);
1214 $$ = (long)linkNextNode((PyrParseNode*)$1, elems);
1216 | arrayelems1 ',' exprseq ':' exprseq
1218 PyrParseNode* elems;
1219 elems = (PyrParseNode*)linkNextNode((PyrParseNode*)$3, (PyrParseNode*)$5);
1220 $$ = (long)linkNextNode((PyrParseNode*)$1, elems);
1225 | arglist1 ',' exprseq
1226 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1229 arglistv1 : '*' exprseq
1231 | arglist1 ',' '*' exprseq
1232 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$4); }
1235 keyarglist1 : keyarg
1236 | keyarglist1 ',' keyarg
1237 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1240 keyarg : keybinop exprseq
1241 { $$ = (long)newPyrPushKeyArgNode((PyrSlotNode*)$1, (PyrParseNode*)$2); }
1244 optkeyarglist : { $$ = 0; }
1245 | ',' keyarglist1 { $$ = $2; }
1249 { $$ = (long)newPyrMultiAssignVarListNode((PyrSlotNode*)$1, NULL); }
1250 | mavarlist ELLIPSIS name
1251 { $$ = (long)newPyrMultiAssignVarListNode((PyrSlotNode*)$1, (PyrSlotNode*)$3); }
1255 | mavarlist ',' name
1256 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1260 : integer { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1261 | floatp { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1262 | ascii { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1263 | string { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1264 | symbol { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1265 | trueobj { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1266 | falseobj { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1267 | nilobj { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1268 | listlit { $$ = (long)newPyrLiteralNode(NULL, (PyrParseNode*)$1); }
1269 | dictlit { $$ = (long)newPyrLiteralNode(NULL, (PyrParseNode*)$1); }
1272 blockliteral : block { $$ = (long)newPyrPushLitNode(NULL, (PyrParseNode*)$1); }
1275 pushname : name { $$ = (long)newPyrPushNameNode((PyrSlotNode*)$1); }
1278 pushliteral : integer { $$ = (long)newPyrPushLitNode((PyrSlotNode*)$1, NULL); }
1279 | floatp { $$ = (long)newPyrPushLitNode((PyrSlotNode*)$1, NULL); }
1280 | ascii { $$ = (long)newPyrPushLitNode((PyrSlotNode*)$1, NULL); }
1281 | string { $$ = (long)newPyrPushLitNode((PyrSlotNode*)$1, NULL); }
1282 | symbol { $$ = (long)newPyrPushLitNode((PyrSlotNode*)$1, NULL); }
1283 | trueobj { $$ = (long)newPyrPushLitNode((PyrSlotNode*)$1, NULL); }
1284 | falseobj { $$ = (long)newPyrPushLitNode((PyrSlotNode*)$1, NULL); }
1285 | nilobj { $$ = (long)newPyrPushLitNode((PyrSlotNode*)$1, NULL); }
1286 | listlit { $$ = (long)newPyrPushLitNode(NULL, (PyrParseNode*)$1); }
1287 | dictlit { $$ = (long)newPyrPushLitNode(NULL, (PyrParseNode*)$1); }
1290 listliteral : integer { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1291 | floatp { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1292 | ascii { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1293 | string { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1294 | symbol { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1295 | name { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1296 | trueobj { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1297 | falseobj { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1298 | nilobj { $$ = (long)newPyrLiteralNode((PyrSlotNode*)$1, NULL); }
1299 | listlit2 { $$ = (long)newPyrLiteralNode(NULL, (PyrParseNode*)$1); }
1300 | dictlit2 { $$ = (long)newPyrLiteralNode(NULL, (PyrParseNode*)$1); }
1303 block : '{' argdecls funcvardecls funcbody '}'
1304 { $$ = (long)newPyrBlockNode((PyrArgListNode*)$2, (PyrVarListNode*)$3,
1305 (PyrParseNode*)$4, false); }
1306 | BEGINCLOSEDFUNC argdecls funcvardecls funcbody '}'
1307 { $$ = (long)newPyrBlockNode((PyrArgListNode*)$2, (PyrVarListNode*)$3,
1308 (PyrParseNode*)$4, true); }
1311 funcvardecls : { $$ = 0; }
1312 | funcvardecls funcvardecl
1313 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$2); }
1316 funcvardecls1 : funcvardecl
1317 | funcvardecls1 funcvardecl
1318 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$2); }
1321 funcvardecl : VAR vardeflist ';'
1322 { $$ = (long)newPyrVarListNode((PyrVarDefNode*)$2, varLocal); }
1325 argdecls : { $$ = 0; }
1326 | ARG vardeflist ';'
1328 $$ = (long)newPyrArgListNode((PyrVarDefNode*)$2, NULL);
1330 | ARG vardeflist0 ELLIPSIS name ';'
1332 $$ = (long)newPyrArgListNode((PyrVarDefNode*)$2, (PyrSlotNode*)$4);
1334 | '|' slotdeflist '|'
1336 $$ = (long)newPyrArgListNode((PyrVarDefNode*)$2, NULL);
1338 | '|' slotdeflist0 ELLIPSIS name '|'
1340 $$ = (long)newPyrArgListNode((PyrVarDefNode*)$2, (PyrSlotNode*)$4);
1344 constdeflist : constdef
1345 | constdeflist optcomma constdef
1346 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1349 constdef : rspec name '=' slotliteral
1350 { $$ = (long)newPyrVarDefNode((PyrSlotNode*)$2, (PyrParseNode*)$4, $1); }
1353 slotdeflist0 : { $$ = 0; }
1357 slotdeflist : slotdef
1358 | slotdeflist optcomma slotdef
1359 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1363 { $$ = (long)newPyrVarDefNode((PyrSlotNode*)$1, NULL, 0); }
1364 | name optequal slotliteral
1365 { $$ = (long)newPyrVarDefNode((PyrSlotNode*)$1, (PyrParseNode*)$3, 0); }
1366 | name optequal '(' exprseq ')'
1368 PyrParseNode* node = (PyrParseNode*)$4;
1370 $$ = (long)newPyrVarDefNode((PyrSlotNode*)$1, node, 0);
1374 vardeflist0 : { $$ = 0; }
1379 | vardeflist ',' vardef
1380 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1384 { $$ = (long)newPyrVarDefNode((PyrSlotNode*)$1, NULL, 0); }
1386 { $$ = (long)newPyrVarDefNode((PyrSlotNode*)$1, (PyrParseNode*)$3, 0); }
1387 | name '(' exprseq ')'
1389 PyrParseNode* node = (PyrParseNode*)$3;
1391 $$ = (long)newPyrVarDefNode((PyrSlotNode*)$1, node, 0);
1395 dictslotdef : exprseq ':' exprseq
1396 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1399 PyrParseNode* key = newPyrPushLitNode((PyrSlotNode*)$1, NULL);
1400 $$ = (long)linkNextNode(key, (PyrParseNode*)$2);
1404 dictslotlist1 : dictslotdef
1405 | dictslotlist1 ',' dictslotdef
1406 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1409 dictslotlist : { $$ = 0; }
1413 rwslotdeflist : rwslotdef
1414 | rwslotdeflist ',' rwslotdef
1415 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1418 rwslotdef : rwspec name
1419 { $$ = (long)newPyrVarDefNode((PyrSlotNode*)$2, NULL, $1); }
1420 | rwspec name '=' slotliteral
1421 { $$ = (long)newPyrVarDefNode((PyrSlotNode*)$2, (PyrParseNode*)$4, $1); }
1424 dictlit : '#' '(' litdictslotlist ')'
1425 { $$ = (long)newPyrLitDictNode((PyrParseNode*)$3); }
1428 dictlit2 : '(' litdictslotlist ')'
1429 { $$ = (long)newPyrLitDictNode((PyrParseNode*)$2); }
1432 litdictslotdef : listliteral ':' listliteral
1433 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1434 | keybinop listliteral
1436 PyrParseNode* key = newPyrPushLitNode((PyrSlotNode*)$1, NULL);
1437 $$ = (long)linkNextNode(key, (PyrParseNode*)$2);
1441 litdictslotlist1 : litdictslotdef
1442 | litdictslotlist1 ',' litdictslotdef
1443 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1446 litdictslotlist : { $$ = 0; }
1452 listlit : '#' '[' literallistc ']'
1453 { $$ = (long)newPyrLitListNode(0, (PyrParseNode*)$3); }
1454 | '#' classname '[' literallistc ']'
1455 { $$ = (long)newPyrLitListNode((PyrParseNode*)$2, (PyrParseNode*)$4); }
1458 listlit2 : '[' literallistc ']'
1459 { $$ = (long)newPyrLitListNode(0, (PyrParseNode*)$2); }
1460 | classname '[' literallistc ']'
1461 { $$ = (long)newPyrLitListNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1464 literallistc : { $$ = 0; }
1465 | literallist1 optcomma
1468 literallist1 : listliteral
1469 | literallist1 ',' listliteral
1470 { $$ = (long)linkNextNode((PyrParseNode*)$1, (PyrParseNode*)$3); }
1473 rwspec : { $$ = rwPrivate; }
1475 { $$ = rwReadOnly; }
1477 { $$ = rwReadWrite; }
1479 { $$ = rwWriteOnly; }
1482 rspec : { $$ = rwPrivate; }
1484 { $$ = rwReadOnly; }
1487 integer : INTEGER { $$ = zzval; }
1488 | '-'INTEGER %prec UMINUS
1491 node = (PyrSlotNode*)zzval;
1492 SetRaw(&node->mSlot, -slotRawInt(&node->mSlot));
1497 floatr : SC_FLOAT { $$ = zzval; }
1498 | '-' SC_FLOAT %prec UMINUS
1501 node = (PyrSlotNode*)zzval;
1502 SetRaw(&node->mSlot, -slotRawFloat(&node->mSlot));
1507 accidental : ACCIDENTAL { $$ = zzval; }
1508 | '-' ACCIDENTAL %prec UMINUS
1511 double intval, fracval;
1512 node = (PyrSlotNode*)zzval;
1513 intval = floor(slotRawFloat(&node->mSlot) + 0.5);
1514 fracval = slotRawFloat(&node->mSlot) - intval;
1515 SetRaw(&node->mSlot, -intval + fracval);
1519 pie : PIE { $$ = zzval; }
1527 node = (PyrSlotNode*)$1;
1528 SetRaw(&node->mSlot, slotRawFloat(&node->mSlot) * pi);
1534 node = (PyrSlotNode*)$1;
1535 ival = slotRawInt(&node->mSlot);
1536 SetFloat(&node->mSlot, ival * pi);
1541 node = (PyrSlotNode*)zzval;
1542 SetFloat(&node->mSlot, pi);
1548 node = (PyrSlotNode*)zzval;
1549 SetFloat(&node->mSlot, -pi);
1554 name : NAME { $$ = zzval; }
1555 | WHILE { $$ = zzval; }
1558 classname : CLASSNAME { $$ = zzval; }
1561 primname : PRIMITIVENAME { $$ = zzval; }
1564 trueobj : TRUEOBJ { $$ = zzval; }
1567 falseobj : FALSEOBJ { $$ = zzval; }
1570 nilobj : NILOBJ { $$ = zzval; }
1573 ascii : ASCII { $$ = zzval; }
1576 symbol : SYMBOL { $$ = zzval; }
1579 string : STRING { $$ = zzval; }
1582 pseudovar : PSEUDOVAR { $$ = zzval; }
1585 binop : BINOP { $$ = zzval; }
1586 | READWRITEVAR { $$ = zzval; }
1587 | '<' { $$ = zzval; }
1588 | '>' { $$ = zzval; }
1589 | '-' { $$ = zzval; }
1590 | '*' { $$ = zzval; }
1591 | '+' { $$ = zzval; }
1592 | '|' { $$ = zzval; }
1595 keybinop : KEYBINOP { $$ = zzval; }
1602 curryarg : CURRYARG { $$ = zzval; }