2 static char luaY_sccsid
[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
7 #define luaY_clearin (luaY_char=(-1))
8 #define luaY_errok (luaY_errflag=0)
9 #define YYRECOVERING (luaY_errflag!=0)
10 #define YYPREFIX "luaY_"
13 char *rcs_luastx
= "$Id: parser.c,v 1.1 1997/06/30 18:59:03 lhf Exp $";
30 /* to avoid warnings generated by yacc */
31 int luaY_parse (void);
32 #define malloc luaI_malloc
33 #define realloc luaI_realloc
34 #define free luaI_free
41 #define CODE_BLOCK 256
46 static Byte
*funcCode
= NULL
;
47 static Byte
**initcode
;
54 static Long varbuffer
[MAXVAR
]; /* variables in an assignment list;
55 it's long to store negative Word values */
56 static int nvarbuffer
=0; /* number of variables at a list */
59 static TaggedString
*localvar
[MAXLOCALS
]; /* store local variable names */
60 static int nlocalvar
=0; /* number of local variables */
62 #define MAXFIELDS FIELDS_PER_FLUSH*2
66 /* Internal functions */
68 static void luaY_error (char *s
)
73 static void check_space (int i
)
75 if (pc
+i
>maxcurr
-1) /* 1 byte free to code HALT of main code */
76 maxcurr
= growvector(&basepc
, maxcurr
, Byte
, codeEM
, MAX_INT
);
79 static void code_byte (Byte c
)
85 static void code_word (Word n
)
87 check_space(sizeof(Word
));
88 memcpy(basepc
+pc
, &n
, sizeof(Word
));
92 static void code_float (real n
)
94 check_space(sizeof(real
));
95 memcpy(basepc
+pc
, &n
, sizeof(real
));
99 static void code_code (TFunc
*tf
)
101 check_space(sizeof(TFunc
*));
102 memcpy(basepc
+pc
, &tf
, sizeof(TFunc
*));
103 pc
+= sizeof(TFunc
*);
106 static void code_word_at (Byte
*p
, int n
)
110 luaY_error("block too big");
111 memcpy(p
, &w
, sizeof(Word
));
114 static void flush_record (int n
)
121 static void flush_list (int m
, int n
)
125 code_byte(STORELIST0
);
129 code_byte(STORELIST
);
133 luaY_error ("list constructor too long");
137 static void store_localvar (TaggedString
*name
, int n
)
139 if (nlocalvar
+n
< MAXLOCALS
)
140 localvar
[nlocalvar
+n
] = name
;
142 luaY_error ("too many local variables");
144 luaI_registerlocalvar(name
, lua_linenumber
);
147 static void add_localvar (TaggedString
*name
)
149 store_localvar(name
, 0);
153 static void add_varbuffer (Long var
)
155 if (nvarbuffer
< MAXVAR
)
156 varbuffer
[nvarbuffer
++] = var
;
158 luaY_error ("variable buffer overflow");
161 static void code_string (Word w
)
163 code_byte(PUSHSTRING
);
167 static void code_constant (TaggedString
*s
)
169 code_string(luaI_findconstant(s
));
172 static void code_number (float f
)
175 if (f
>= 0 && f
<= (float)MAX_WORD
&& (float)(i
=(Word
)f
) == f
) {
176 /* f has an (short) integer value */
177 if (i
<= 2) code_byte(PUSH0
+ i
);
191 code_byte(PUSHFLOAT
);
197 ** Search a local name and if find return its index. If do not find return -1
199 static int lua_localname (TaggedString
*n
)
202 for (i
=nlocalvar
-1; i
>= 0; i
--)
203 if (n
== localvar
[i
]) return i
; /* local var */
204 return -1; /* global var */
208 ** Push a variable given a number. If number is positive, push global variable
209 ** indexed by (number -1). If negative, push local indexed by ABS(number)-1.
210 ** Otherwise, if zero, push indexed variable (record).
212 static void lua_pushvar (Long number
)
214 if (number
> 0) /* global var */
216 code_byte(PUSHGLOBAL
);
219 else if (number
< 0) /* local var */
221 number
= (-number
) - 1;
222 if (number
< 10) code_byte(PUSHLOCAL0
+ number
);
225 code_byte(PUSHLOCAL
);
231 code_byte(PUSHINDEXED
);
235 static void lua_codeadjust (int n
)
237 if (n
+nlocalvar
== 0)
242 code_byte(n
+nlocalvar
);
246 static void change2main (void)
248 /* (re)store main values */
249 pc
=maincode
; basepc
=*initcode
; maxcurr
=maxmain
;
253 static void savemain (void)
255 /* save main values */
256 maincode
=pc
; *initcode
=basepc
; maxmain
=maxcurr
;
259 static void init_func (void)
261 if (funcCode
== NULL
) /* first function */
263 funcCode
= newvector(CODE_BLOCK
, Byte
);
264 maxcode
= CODE_BLOCK
;
266 savemain(); /* save main values */
267 /* set func values */
268 pc
=0; basepc
=funcCode
; maxcurr
=maxcode
;
270 luaI_codedebugline(lua_linenumber
);
273 static void codereturn (void)
280 code_byte(nlocalvar
);
284 void luaI_codedebugline (int line
)
286 static int lastline
= 0;
287 if (lua_debug
&& line
!= lastline
)
295 static int adjust_functioncall (Long exp
, int i
)
298 return -exp
; /* exp is -list length */
301 int temp
= basepc
[exp
];
307 static void adjust_mult_assign (int vars
, Long exps
, int temps
)
310 { /* must correct function call */
311 int diff
= vars
- basepc
[exps
];
313 adjust_functioncall(exps
, diff
);
316 adjust_functioncall(exps
, 0);
317 lua_codeadjust(temps
);
320 else if (vars
!= -exps
)
321 lua_codeadjust(temps
);
324 static int close_parlist (int dots
)
331 code_byte(nlocalvar
);
332 add_localvar(luaI_createfixedstring("arg"));
334 return lua_linenumber
;
337 static void storesinglevar (Long v
)
339 if (v
> 0) /* global var */
341 code_byte(STOREGLOBAL
);
344 else if (v
< 0) /* local var */
346 int number
= (-v
) - 1;
347 if (number
< 10) code_byte(STORELOCAL0
+ number
);
350 code_byte(STORELOCAL
);
355 code_byte(STOREINDEXED0
);
358 static void lua_codestore (int i
)
360 if (varbuffer
[i
] != 0) /* global or local var */
361 storesinglevar(varbuffer
[i
]);
362 else /* indexed var */
365 int upper
=0; /* number of indexed variables upper */
366 int param
; /* number of itens until indexed expression */
367 for (j
=i
+1; j
<nvarbuffer
; j
++)
368 if (varbuffer
[j
] == 0) upper
++;
371 code_byte(STOREINDEXED0
);
374 code_byte(STOREINDEXED
);
380 static void codeIf (Long thenAdd
, Long elseAdd
)
382 Long elseinit
= elseAdd
+sizeof(Word
)+1;
383 if (pc
== elseinit
) /* no else */
385 pc
-= sizeof(Word
)+1;
390 basepc
[elseAdd
] = JMP
;
391 code_word_at(basepc
+elseAdd
+1, pc
-elseinit
);
393 basepc
[thenAdd
] = IFFJMP
;
394 code_word_at(basepc
+thenAdd
+1,elseinit
-(thenAdd
+sizeof(Word
)+1));
401 void lua_parse (TFunc
*tf
)
403 initcode
= &(tf
->code
);
404 *initcode
= newvector(CODE_BLOCK
, Byte
);
406 maxmain
= CODE_BLOCK
;
408 if (luaY_parse ()) lua_error("parse error");
410 (*initcode
)[maincode
++] = RETCODE0
;
413 { static void PrintCode (Byte
*c
, Byte
*end
);
414 PrintCode(*initcode
,*initcode
+maincode
); }
431 #define WRONGTOKEN 257
458 #define YYERRCODE 256
459 short luaY_lhs
[] = { -1,
460 0, 24, 24, 24, 28, 22, 22, 23, 31, 31,
461 27, 27, 26, 34, 26, 35, 26, 26, 26, 26,
462 33, 33, 33, 36, 30, 25, 25, 1, 32, 5,
463 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
464 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
465 38, 5, 39, 5, 40, 37, 4, 8, 8, 7,
466 7, 2, 2, 3, 41, 3, 17, 17, 18, 18,
467 19, 19, 42, 9, 9, 14, 14, 43, 43, 12,
468 12, 13, 13, 44, 45, 45, 15, 15, 16, 16,
469 6, 6, 20, 20, 20, 21, 29, 10, 10, 11,
472 short luaY_len
[] = { 2,
473 2, 0, 3, 2, 3, 1, 3, 5, 0, 3,
474 0, 1, 8, 0, 8, 0, 6, 3, 1, 3,
475 0, 2, 7, 0, 3, 0, 3, 0, 1, 3,
476 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
477 3, 3, 2, 1, 1, 1, 1, 1, 1, 2,
478 0, 5, 0, 5, 0, 4, 2, 1, 3, 3,
479 1, 0, 1, 1, 0, 4, 0, 1, 1, 3,
480 1, 1, 0, 3, 2, 0, 2, 0, 1, 0,
481 2, 1, 3, 3, 3, 1, 0, 2, 1, 3,
482 1, 3, 1, 4, 3, 1, 1, 1, 3, 0,
485 short luaY_defred
[] = { 2,
486 0, 0, 0, 14, 16, 0, 0, 0, 96, 19,
487 0, 0, 0, 93, 1, 0, 4, 0, 48, 46,
488 47, 0, 0, 0, 49, 29, 97, 0, 0, 44,
489 0, 0, 24, 0, 0, 0, 0, 98, 0, 0,
490 0, 0, 0, 0, 0, 57, 61, 12, 3, 0,
491 0, 0, 0, 0, 0, 28, 28, 28, 0, 0,
492 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
493 0, 0, 0, 9, 27, 65, 0, 0, 20, 0,
494 5, 0, 0, 0, 0, 0, 59, 0, 95, 30,
495 24, 51, 53, 0, 0, 0, 0, 0, 0, 0,
496 0, 0, 0, 0, 0, 0, 0, 0, 0, 73,
497 0, 0, 82, 0, 28, 0, 0, 0, 0, 99,
498 72, 71, 0, 0, 69, 7, 60, 94, 28, 0,
499 0, 0, 56, 0, 75, 0, 0, 88, 0, 24,
500 0, 25, 0, 0, 24, 0, 0, 0, 0, 85,
501 86, 83, 0, 74, 0, 0, 28, 17, 10, 0,
502 70, 24, 0, 0, 77, 0, 0, 8, 22, 0,
503 13, 81, 15, 28, 24, 28, 0, 23,
505 short luaY_dgoto
[] = { 1,
506 91, 34, 35, 25, 26, 11, 46, 12, 108, 39,
507 79, 165, 109, 154, 110, 111, 123, 124, 125, 27,
508 14, 41, 81, 2, 15, 16, 49, 17, 28, 73,
509 117, 37, 164, 32, 33, 74, 30, 130, 131, 31,
510 118, 136, 135, 113, 114,
512 short luaY_sindex
[] = { 0,
513 0, 288, -34, 0, 0, -34, -238, -223, 0, 0,
514 -6, 22, 0, 0, 0, 14, 0, 150, 0, 0,
515 0, -34, -34, -34, 0, 0, 0, 150, 547, 0,
516 -46, -34, 0, 14, 34, 0, 212, 0, -5, 0,
517 39, 156, -34, -223, -34, 0, 0, 0, 0, -194,
518 -34, -193, -4, -4, 48, 0, 0, 0, -34, -34,
519 -34, -34, -34, -34, -34, -34, -34, -34, -34, -34,
520 -38, 481, -173, 0, 0, 0, -34, -146, 0, -234,
521 0, -138, 34, 0, -15, 96, 0, 753, 0, 0,
522 0, 0, 0, -30, -30, -30, -30, -30, -30, -20,
523 -12, -12, -4, -4, -4, 0, -34, 16, 95, 0,
524 98, 212, 0, 82, 0, -34, 328, -34, 34, 0,
525 0, 0, 103, 101, 0, 0, 0, 0, 0, -34,
526 -34, 1181, 0, -91, 0, 92, -34, 0, -34, 0,
527 212, 0, 14, 0, 0, -234, -233, 118, 118, 0,
528 0, 0, -91, 0, 212, 212, 0, 0, 0, -105,
529 0, 0, -34, -103, 0, 95, -101, 0, 0, 1105,
530 0, 0, 0, 0, 0, 0, -233, 0,
532 short luaY_rindex
[] = { 0,
533 0, 169, 52, 0, 0, 173, 0, 0, 0, 0,
534 0, 52, 508, 0, 0, 146, 0, -36, 0, 0,
535 0, 52, 52, 52, 0, 0, 0, 1, 0, 0,
536 0, 52, 0, 47, 461, 436, 0, 0, 197, 76,
537 0, 0, 52, 0, -32, 0, 0, 0, 0, 0,
538 52, 0, 24, 59, 1195, 0, 0, 0, 52, 52,
539 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
540 -27, 0, 0, 0, 0, 0, 52, 0, 0, 129,
541 0, 0, 311, 142, 0, 0, 0, 0, 0, 0,
542 0, 0, 0, 746, 776, 799, 821, 844, 866, 505,
543 383, 410, 88, 112, 359, 1174, 52, 0, 51, 0,
544 -40, -10, 0, 0, 0, 52, -153, 52, 921, 0,
545 0, 0, 0, 144, 0, 0, 0, 0, 0, 52,
546 52, 0, 0, 62, 0, 64, -26, 0, 52, 0,
547 939, 0, 682, 474, 0, 0, -77, 894, 1137, 0,
548 0, 0, 66, 0, 13, -18, 0, 0, 0, 0,
549 0, 0, 52, 0, 0, 51, 0, 0, 0, 0,
550 0, 0, 0, 0, 0, 0, -77, 0,
552 short luaY_gindex
[] = { 0,
553 53, 147, -23, 3, 134, 0, 0, 0, 0, 0,
554 0, 0, 40, 0, 0, 0, 0, 0, 49, 6,
555 0, 0, 0, 0, 81, 83, -16, 0, 8, -70,
556 0, 1445, 27, 0, 0, 0, 187, 0, 0, 0,
559 #define YYTABLESIZE 1608
560 short luaY_table
[] = { 107,
561 45, 24, 138, 58, 10, 24, 22, 13, 62, 18,
562 22, 68, 66, 40, 67, 42, 69, 75, 78, 83,
563 129, 68, 66, 43, 67, 84, 69, 162, 163, 68,
564 52, 87, 79, 89, 69, 38, 121, 44, 78, 122,
565 58, 45, 45, 45, 45, 45, 11, 45, 89, 84,
566 9, 85, 107, 119, 43, 77, 90, 172, 50, 45,
567 45, 45, 45, 70, 43, 43, 43, 43, 43, 157,
568 43, 90, 48, 70, 160, 51, 71, 76, 80, 87,
569 89, 70, 43, 43, 78, 43, 58, 39, 90, 70,
570 55, 169, 116, 45, 45, 55, 55, 87, 79, 50,
571 50, 50, 50, 50, 176, 50, 84, 26, 26, 92,
572 93, 40, 26, 26, 89, 6, 43, 50, 50, 10,
573 50, 97, 13, 58, 18, 45, 159, 120, 39, 39,
574 39, 39, 39, 97, 39, 126, 127, 90, 134, 36,
575 133, 137, 139, 145, 146, 11, 39, 39, 43, 39,
576 153, 50, 40, 40, 40, 40, 40, 55, 40, 68,
577 66, 168, 67, 171, 69, 173, 97, 140, 26, 67,
578 40, 40, 62, 40, 55, 78, 36, 62, 36, 61,
579 39, 147, 151, 50, 68, 92, 79, 97, 76, 21,
580 80, 86, 166, 158, 161, 52, 100, 142, 47, 143,
581 152, 52, 92, 178, 40, 0, 0, 50, 0, 167,
582 36, 70, 39, 82, 0, 0, 0, 0, 0, 19,
583 0, 0, 0, 19, 0, 0, 175, 0, 177, 0,
584 0, 62, 97, 20, 21, 106, 40, 20, 21, 9,
585 51, 0, 0, 0, 23, 0, 51, 0, 23, 0,
586 65, 144, 0, 68, 66, 100, 67, 0, 69, 45,
587 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
588 45, 62, 0, 61, 45, 45, 45, 45, 45, 45,
589 45, 45, 43, 43, 43, 43, 43, 43, 43, 43,
590 43, 43, 43, 43, 0, 55, 0, 43, 43, 43,
591 43, 43, 43, 43, 43, 70, 0, 11, 11, 0,
592 18, 0, 11, 11, 0, 0, 0, 50, 50, 50,
593 50, 50, 50, 50, 50, 50, 50, 50, 50, 0,
594 0, 0, 50, 50, 50, 50, 50, 50, 50, 50,
595 0, 0, 0, 0, 0, 0, 39, 39, 39, 39,
596 39, 39, 39, 39, 39, 39, 39, 39, 41, 0,
597 0, 39, 39, 39, 39, 39, 39, 39, 39, 18,
598 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
599 40, 40, 37, 0, 0, 40, 40, 40, 40, 40,
600 40, 40, 40, 0, 59, 60, 63, 64, 65, 41,
601 41, 41, 41, 41, 11, 41, 0, 0, 11, 38,
602 11, 0, 0, 11, 11, 11, 0, 41, 41, 11,
603 41, 0, 0, 37, 0, 37, 37, 37, 0, 0,
604 0, 0, 0, 62, 62, 64, 0, 0, 62, 62,
605 0, 37, 37, 0, 37, 0, 0, 0, 0, 0,
606 38, 41, 38, 38, 38, 100, 0, 100, 100, 100,
607 63, 100, 100, 100, 100, 100, 100, 0, 38, 38,
608 100, 38, 0, 66, 0, 37, 64, 29, 29, 64,
609 29, 0, 29, 41, 0, 0, 57, 58, 59, 60,
610 63, 64, 65, 0, 64, 29, 0, 29, 0, 0,
611 0, 63, 38, 0, 42, 0, 0, 37, 0, 0,
612 0, 0, 0, 0, 66, 29, 29, 66, 29, 63,
613 29, 0, 68, 66, 0, 67, 0, 69, 0, 29,
614 0, 0, 66, 29, 38, 29, 0, 0, 0, 0,
615 62, 0, 61, 0, 0, 42, 3, 97, 42, 0,
616 4, 91, 5, 97, 0, 6, 7, 8, 0, 0,
617 0, 9, 0, 42, 42, 97, 42, 29, 91, 18,
618 0, 18, 18, 18, 70, 18, 18, 18, 18, 18,
619 18, 0, 0, 0, 18, 0, 3, 0, 68, 66,
620 4, 67, 5, 69, 0, 6, 7, 42, 97, 0,
621 0, 9, 0, 0, 0, 0, 62, 0, 61, 0,
622 0, 0, 0, 0, 0, 0, 0, 41, 41, 41,
623 41, 41, 41, 41, 41, 41, 41, 41, 41, 42,
624 97, 0, 41, 41, 41, 41, 41, 41, 41, 41,
625 70, 37, 37, 37, 37, 37, 37, 37, 37, 37,
626 37, 37, 37, 0, 0, 0, 37, 37, 37, 37,
627 37, 37, 37, 37, 0, 0, 0, 0, 38, 38,
628 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
629 0, 0, 0, 38, 38, 38, 38, 38, 38, 38,
630 38, 0, 0, 0, 64, 0, 64, 64, 64, 0,
631 64, 64, 64, 64, 64, 64, 0, 0, 0, 64,
632 29, 29, 29, 29, 29, 29, 29, 0, 0, 0,
633 0, 63, 63, 0, 0, 0, 63, 63, 0, 0,
634 0, 0, 66, 0, 66, 66, 66, 0, 66, 66,
635 66, 66, 66, 66, 115, 31, 0, 66, 29, 29,
636 29, 29, 29, 29, 29, 57, 58, 59, 60, 63,
637 64, 65, 0, 42, 42, 42, 42, 42, 42, 42,
638 42, 42, 42, 42, 42, 34, 0, 0, 42, 42,
639 42, 42, 42, 42, 42, 42, 31, 0, 0, 31,
640 0, 0, 0, 0, 68, 66, 0, 67, 33, 69,
641 0, 0, 0, 0, 31, 31, 56, 31, 0, 0,
642 0, 0, 62, 0, 61, 0, 34, 0, 0, 34,
643 32, 57, 58, 59, 60, 63, 64, 65, 0, 0,
644 0, 0, 0, 0, 34, 34, 0, 34, 31, 33,
645 0, 0, 33, 35, 0, 128, 70, 0, 0, 0,
646 0, 0, 0, 0, 0, 0, 0, 33, 33, 0,
647 33, 32, 0, 0, 32, 36, 0, 0, 34, 0,
648 31, 0, 0, 0, 0, 0, 0, 0, 0, 32,
649 32, 0, 32, 0, 35, 0, 0, 35, 0, 0,
650 0, 33, 0, 52, 0, 0, 0, 0, 0, 0,
651 34, 0, 35, 35, 0, 35, 36, 0, 0, 36,
652 0, 0, 0, 32, 0, 0, 0, 0, 0, 0,
653 101, 0, 0, 33, 36, 36, 0, 36, 0, 0,
654 0, 0, 0, 0, 52, 0, 35, 52, 28, 0,
655 11, 0, 11, 11, 11, 32, 11, 11, 11, 11,
656 11, 0, 52, 0, 0, 11, 0, 0, 36, 0,
657 0, 0, 0, 0, 0, 0, 0, 0, 35, 0,
658 0, 0, 0, 0, 0, 0, 0, 0, 0, 101,
659 0, 0, 0, 0, 0, 0, 52, 0, 0, 0,
660 36, 0, 0, 0, 0, 0, 0, 28, 0, 0,
661 0, 0, 0, 0, 31, 31, 31, 31, 31, 31,
662 31, 31, 31, 31, 31, 31, 0, 0, 52, 31,
663 31, 31, 31, 31, 31, 31, 0, 57, 58, 59,
664 60, 63, 64, 65, 34, 34, 34, 34, 34, 34,
665 34, 34, 34, 34, 34, 34, 0, 0, 0, 34,
666 34, 34, 34, 34, 34, 34, 0, 33, 33, 33,
667 33, 33, 33, 33, 33, 33, 33, 33, 33, 0,
668 0, 0, 33, 33, 33, 33, 33, 33, 33, 32,
669 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
670 32, 0, 0, 0, 32, 32, 32, 32, 32, 32,
671 32, 0, 35, 35, 35, 35, 35, 35, 35, 35,
672 35, 35, 35, 35, 0, 0, 0, 35, 35, 35,
673 35, 35, 35, 35, 36, 36, 36, 36, 36, 36,
674 36, 36, 36, 36, 36, 36, 54, 0, 0, 36,
675 36, 36, 36, 36, 36, 36, 68, 66, 0, 67,
676 0, 69, 52, 52, 52, 52, 52, 52, 52, 52,
677 52, 52, 52, 52, 62, 0, 61, 52, 52, 52,
678 0, 0, 0, 0, 0, 0, 0, 54, 0, 101,
679 54, 101, 101, 101, 0, 101, 101, 101, 101, 101,
680 101, 0, 0, 0, 101, 54, 0, 28, 70, 28,
681 28, 28, 0, 28, 28, 28, 28, 28, 28, 0,
682 0, 0, 28, 96, 0, 96, 96, 96, 96, 96,
683 96, 0, 68, 66, 0, 67, 0, 69, 0, 54,
684 0, 96, 96, 96, 86, 96, 29, 29, 0, 29,
685 62, 29, 61, 0, 0, 0, 0, 0, 0, 0,
686 0, 0, 0, 0, 29, 0, 29, 0, 0, 0,
687 0, 54, 0, 0, 96, 0, 0, 96, 0, 0,
688 0, 0, 0, 150, 70, 0, 0, 0, 0, 0,
689 0, 0, 0, 0, 0, 0, 0, 0, 29, 0,
690 0, 0, 0, 0, 0, 0, 96, 0, 96, 0,
691 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
692 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
693 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
694 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
695 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
696 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
697 0, 0, 0, 0, 174, 0, 0, 0, 0, 0,
698 0, 0, 0, 0, 0, 0, 0, 0, 0, 57,
699 58, 59, 60, 63, 64, 65, 0, 0, 0, 0,
700 0, 0, 0, 0, 0, 54, 54, 54, 54, 54,
701 54, 54, 54, 54, 54, 54, 54, 0, 0, 0,
702 54, 54, 54, 0, 0, 0, 0, 0, 0, 0,
703 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
704 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
705 0, 0, 0, 0, 0, 0, 0, 29, 96, 96,
706 96, 96, 96, 96, 96, 57, 58, 59, 60, 63,
707 64, 65, 0, 0, 0, 0, 53, 54, 0, 29,
708 29, 29, 29, 29, 29, 29, 72, 0, 0, 0,
709 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
710 0, 0, 0, 0, 0, 88, 0, 0, 0, 0,
711 0, 0, 0, 94, 95, 96, 97, 98, 99, 100,
712 101, 102, 103, 104, 105, 112, 0, 0, 0, 0,
713 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
714 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
715 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
716 0, 132, 0, 0, 0, 0, 0, 0, 0, 0,
717 141, 0, 0, 0, 0, 0, 0, 0, 0, 0,
718 0, 0, 0, 0, 148, 149, 0, 0, 0, 0,
719 0, 155, 0, 156, 0, 0, 0, 0, 0, 0,
720 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
721 0, 0, 0, 0, 0, 0, 0, 170,
723 short luaY_check
[] = { 91,
724 0, 40, 111, 40, 2, 40, 45, 2, 41, 2,
725 45, 42, 43, 8, 45, 8, 47, 34, 59, 43,
726 91, 42, 43, 0, 45, 44, 47, 261, 262, 42,
727 46, 59, 59, 44, 47, 274, 271, 44, 44, 274,
728 40, 41, 42, 43, 44, 45, 0, 47, 59, 44,
729 274, 44, 91, 77, 61, 61, 44, 166, 0, 59,
730 60, 40, 62, 94, 41, 42, 43, 44, 45, 140,
731 47, 59, 59, 94, 145, 91, 123, 44, 40, 274,
732 274, 94, 59, 60, 125, 62, 123, 0, 41, 94,
733 123, 162, 266, 93, 94, 123, 123, 125, 125, 41,
734 42, 43, 44, 45, 175, 47, 125, 261, 262, 57,
735 58, 0, 266, 267, 125, 40, 93, 59, 60, 117,
736 62, 46, 117, 123, 117, 125, 143, 274, 41, 42,
737 43, 44, 45, 58, 47, 274, 41, 125, 44, 6,
738 125, 44, 61, 41, 44, 0, 59, 60, 125, 62,
739 59, 93, 41, 42, 43, 44, 45, 24, 47, 42,
740 43, 267, 45, 267, 47, 267, 91, 115, 0, 41,
741 59, 60, 0, 62, 123, 125, 43, 60, 45, 62,
742 93, 129, 274, 125, 41, 44, 125, 46, 125, 267,
743 125, 45, 153, 141, 146, 46, 0, 117, 12, 117,
744 134, 46, 61, 177, 93, -1, -1, 58, -1, 157,
745 77, 94, 125, 58, -1, -1, -1, -1, -1, 258,
746 -1, -1, -1, 258, -1, -1, 174, -1, 176, -1,
747 -1, 59, 91, 272, 273, 274, 125, 272, 273, 274,
748 91, -1, -1, -1, 283, -1, 91, -1, 283, -1,
749 281, 118, -1, 42, 43, 59, 45, -1, 47, 259,
750 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
751 270, 60, -1, 62, 274, 275, 276, 277, 278, 279,
752 280, 281, 259, 260, 261, 262, 263, 264, 265, 266,
753 267, 268, 269, 270, -1, 123, -1, 274, 275, 276,
754 277, 278, 279, 280, 281, 94, -1, 261, 262, -1,
755 0, -1, 266, 267, -1, -1, -1, 259, 260, 261,
756 262, 263, 264, 265, 266, 267, 268, 269, 270, -1,
757 -1, -1, 274, 275, 276, 277, 278, 279, 280, 281,
758 -1, -1, -1, -1, -1, -1, 259, 260, 261, 262,
759 263, 264, 265, 266, 267, 268, 269, 270, 0, -1,
760 -1, 274, 275, 276, 277, 278, 279, 280, 281, 59,
761 259, 260, 261, 262, 263, 264, 265, 266, 267, 268,
762 269, 270, 0, -1, -1, 274, 275, 276, 277, 278,
763 279, 280, 281, -1, 277, 278, 279, 280, 281, 41,
764 42, 43, 44, 45, 259, 47, -1, -1, 263, 0,
765 265, -1, -1, 268, 269, 270, -1, 59, 60, 274,
766 62, -1, -1, 41, -1, 43, 44, 45, -1, -1,
767 -1, -1, -1, 261, 262, 0, -1, -1, 266, 267,
768 -1, 59, 60, -1, 62, -1, -1, -1, -1, -1,
769 41, 93, 43, 44, 45, 259, -1, 261, 262, 263,
770 0, 265, 266, 267, 268, 269, 270, -1, 59, 60,
771 274, 62, -1, 0, -1, 93, 41, 42, 43, 44,
772 45, -1, 47, 125, -1, -1, 275, 276, 277, 278,
773 279, 280, 281, -1, 59, 60, -1, 62, -1, -1,
774 -1, 41, 93, -1, 0, -1, -1, 125, -1, -1,
775 -1, -1, -1, -1, 41, 42, 43, 44, 45, 59,
776 47, -1, 42, 43, -1, 45, -1, 47, -1, 94,
777 -1, -1, 59, 60, 125, 62, -1, -1, -1, -1,
778 60, -1, 62, -1, -1, 41, 259, 40, 44, -1,
779 263, 44, 265, 46, -1, 268, 269, 270, -1, -1,
780 -1, 274, -1, 59, 60, 58, 62, 94, 61, 259,
781 -1, 261, 262, 263, 94, 265, 266, 267, 268, 269,
782 270, -1, -1, -1, 274, -1, 259, -1, 42, 43,
783 263, 45, 265, 47, -1, 268, 269, 93, 91, -1,
784 -1, 274, -1, -1, -1, -1, 60, -1, 62, -1,
785 -1, -1, -1, -1, -1, -1, -1, 259, 260, 261,
786 262, 263, 264, 265, 266, 267, 268, 269, 270, 125,
787 123, -1, 274, 275, 276, 277, 278, 279, 280, 281,
788 94, 259, 260, 261, 262, 263, 264, 265, 266, 267,
789 268, 269, 270, -1, -1, -1, 274, 275, 276, 277,
790 278, 279, 280, 281, -1, -1, -1, -1, 259, 260,
791 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
792 -1, -1, -1, 274, 275, 276, 277, 278, 279, 280,
793 281, -1, -1, -1, 259, -1, 261, 262, 263, -1,
794 265, 266, 267, 268, 269, 270, -1, -1, -1, 274,
795 275, 276, 277, 278, 279, 280, 281, -1, -1, -1,
796 -1, 261, 262, -1, -1, -1, 266, 267, -1, -1,
797 -1, -1, 259, -1, 261, 262, 263, -1, 265, 266,
798 267, 268, 269, 270, 264, 0, -1, 274, 275, 276,
799 277, 278, 279, 280, 281, 275, 276, 277, 278, 279,
800 280, 281, -1, 259, 260, 261, 262, 263, 264, 265,
801 266, 267, 268, 269, 270, 0, -1, -1, 274, 275,
802 276, 277, 278, 279, 280, 281, 41, -1, -1, 44,
803 -1, -1, -1, -1, 42, 43, -1, 45, 0, 47,
804 -1, -1, -1, -1, 59, 60, 260, 62, -1, -1,
805 -1, -1, 60, -1, 62, -1, 41, -1, -1, 44,
806 0, 275, 276, 277, 278, 279, 280, 281, -1, -1,
807 -1, -1, -1, -1, 59, 60, -1, 62, 93, 41,
808 -1, -1, 44, 0, -1, 93, 94, -1, -1, -1,
809 -1, -1, -1, -1, -1, -1, -1, 59, 60, -1,
810 62, 41, -1, -1, 44, 0, -1, -1, 93, -1,
811 125, -1, -1, -1, -1, -1, -1, -1, -1, 59,
812 60, -1, 62, -1, 41, -1, -1, 44, -1, -1,
813 -1, 93, -1, 0, -1, -1, -1, -1, -1, -1,
814 125, -1, 59, 60, -1, 62, 41, -1, -1, 44,
815 -1, -1, -1, 93, -1, -1, -1, -1, -1, -1,
816 0, -1, -1, 125, 59, 60, -1, 62, -1, -1,
817 -1, -1, -1, -1, 41, -1, 93, 44, 0, -1,
818 259, -1, 261, 262, 263, 125, 265, 266, 267, 268,
819 269, -1, 59, -1, -1, 274, -1, -1, 93, -1,
820 -1, -1, -1, -1, -1, -1, -1, -1, 125, -1,
821 -1, -1, -1, -1, -1, -1, -1, -1, -1, 59,
822 -1, -1, -1, -1, -1, -1, 93, -1, -1, -1,
823 125, -1, -1, -1, -1, -1, -1, 59, -1, -1,
824 -1, -1, -1, -1, 259, 260, 261, 262, 263, 264,
825 265, 266, 267, 268, 269, 270, -1, -1, 125, 274,
826 275, 276, 277, 278, 279, 280, -1, 275, 276, 277,
827 278, 279, 280, 281, 259, 260, 261, 262, 263, 264,
828 265, 266, 267, 268, 269, 270, -1, -1, -1, 274,
829 275, 276, 277, 278, 279, 280, -1, 259, 260, 261,
830 262, 263, 264, 265, 266, 267, 268, 269, 270, -1,
831 -1, -1, 274, 275, 276, 277, 278, 279, 280, 259,
832 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
833 270, -1, -1, -1, 274, 275, 276, 277, 278, 279,
834 280, -1, 259, 260, 261, 262, 263, 264, 265, 266,
835 267, 268, 269, 270, -1, -1, -1, 274, 275, 276,
836 277, 278, 279, 280, 259, 260, 261, 262, 263, 264,
837 265, 266, 267, 268, 269, 270, 0, -1, -1, 274,
838 275, 276, 277, 278, 279, 280, 42, 43, -1, 45,
839 -1, 47, 259, 260, 261, 262, 263, 264, 265, 266,
840 267, 268, 269, 270, 60, -1, 62, 274, 275, 276,
841 -1, -1, -1, -1, -1, -1, -1, 41, -1, 259,
842 44, 261, 262, 263, -1, 265, 266, 267, 268, 269,
843 270, -1, -1, -1, 274, 59, -1, 259, 94, 261,
844 262, 263, -1, 265, 266, 267, 268, 269, 270, -1,
845 -1, -1, 274, 40, -1, 42, 43, 44, 45, 46,
846 47, -1, 42, 43, -1, 45, -1, 47, -1, 93,
847 -1, 58, 59, 60, 61, 62, 42, 43, -1, 45,
848 60, 47, 62, -1, -1, -1, -1, -1, -1, -1,
849 -1, -1, -1, -1, 60, -1, 62, -1, -1, -1,
850 -1, 125, -1, -1, 91, -1, -1, 94, -1, -1,
851 -1, -1, -1, 93, 94, -1, -1, -1, -1, -1,
852 -1, -1, -1, -1, -1, -1, -1, -1, 94, -1,
853 -1, -1, -1, -1, -1, -1, 123, -1, 125, -1,
854 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
855 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
856 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
857 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
858 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
859 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
860 -1, -1, -1, -1, 260, -1, -1, -1, -1, -1,
861 -1, -1, -1, -1, -1, -1, -1, -1, -1, 275,
862 276, 277, 278, 279, 280, 281, -1, -1, -1, -1,
863 -1, -1, -1, -1, -1, 259, 260, 261, 262, 263,
864 264, 265, 266, 267, 268, 269, 270, -1, -1, -1,
865 274, 275, 276, -1, -1, -1, -1, -1, -1, -1,
866 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
867 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
868 -1, -1, -1, -1, -1, -1, -1, 3, 275, 276,
869 277, 278, 279, 280, 281, 275, 276, 277, 278, 279,
870 280, 281, -1, -1, -1, -1, 22, 23, -1, 275,
871 276, 277, 278, 279, 280, 281, 32, -1, -1, -1,
872 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
873 -1, -1, -1, -1, -1, 51, -1, -1, -1, -1,
874 -1, -1, -1, 59, 60, 61, 62, 63, 64, 65,
875 66, 67, 68, 69, 70, 71, -1, -1, -1, -1,
876 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
877 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
878 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
879 -1, 107, -1, -1, -1, -1, -1, -1, -1, -1,
880 116, -1, -1, -1, -1, -1, -1, -1, -1, -1,
881 -1, -1, -1, -1, 130, 131, -1, -1, -1, -1,
882 -1, 137, -1, 139, -1, -1, -1, -1, -1, -1,
883 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
884 -1, -1, -1, -1, -1, -1, -1, 163,
890 #define YYMAXTOKEN 283
892 char *luaY_name
[] = {
893 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
894 0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,
895 "':'","';'","'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
896 0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
897 0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
898 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
899 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
900 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"WRONGTOKEN","NIL","IF","THEN","ELSE",
901 "ELSEIF","WHILE","DO","REPEAT","UNTIL","END","RETURN","LOCAL","FUNCTION","DOTS",
902 "NUMBER","STRING","NAME","AND","OR","EQ","NE","LE","GE","CONC","UNARY","NOT",
904 char *luaY_rule
[] = {
906 "chunk : chunklist ret",
908 "chunklist : chunklist stat sc",
909 "chunklist : chunklist function",
910 "function : FUNCTION funcname body",
912 "funcname : varexp ':' NAME",
913 "body : '(' parlist ')' block END",
915 "statlist : statlist stat sc",
918 "stat : IF expr1 THEN PrepJump block PrepJump elsepart END",
920 "stat : WHILE $$1 expr1 DO PrepJump block PrepJump END",
922 "stat : REPEAT $$2 block UNTIL expr1 PrepJump",
923 "stat : varlist1 '=' exprlist1",
924 "stat : functioncall",
925 "stat : LOCAL localdeclist decinit",
927 "elsepart : ELSE block",
928 "elsepart : ELSEIF expr1 THEN PrepJump block PrepJump elsepart",
930 "block : $$3 statlist ret",
932 "ret : RETURN exprlist sc",
935 "expr : '(' expr ')'",
936 "expr : expr1 EQ expr1",
937 "expr : expr1 '<' expr1",
938 "expr : expr1 '>' expr1",
939 "expr : expr1 NE expr1",
940 "expr : expr1 LE expr1",
941 "expr : expr1 GE expr1",
942 "expr : expr1 '+' expr1",
943 "expr : expr1 '-' expr1",
944 "expr : expr1 '*' expr1",
945 "expr : expr1 '/' expr1",
946 "expr : expr1 '^' expr1",
947 "expr : expr1 CONC expr1",
954 "expr : functioncall",
957 "expr : expr1 AND PrepJump $$4 expr1",
959 "expr : expr1 OR PrepJump $$5 expr1",
961 "table : $$6 '{' fieldlist '}'",
962 "functioncall : funcvalue funcParams",
963 "funcvalue : varexp",
964 "funcvalue : varexp ':' NAME",
965 "funcParams : '(' exprlist ')'",
966 "funcParams : table",
968 "exprlist : exprlist1",
971 "exprlist1 : exprlist1 ',' $$7 expr",
973 "parlist : parlist1",
975 "parlist1 : parlist1 ',' par",
979 "fieldlist : lfieldlist $$8 semicolonpart",
980 "fieldlist : ffieldlist1 lastcomma",
982 "semicolonpart : ';' ffieldlist",
986 "ffieldlist : ffieldlist1 lastcomma",
987 "ffieldlist1 : ffield",
988 "ffieldlist1 : ffieldlist1 ',' ffield",
989 "ffield : ffieldkey '=' expr1",
990 "ffieldkey : '[' expr1 ']'",
993 "lfieldlist : lfieldlist1 lastcomma",
994 "lfieldlist1 : expr1",
995 "lfieldlist1 : lfieldlist1 ',' expr1",
997 "varlist1 : varlist1 ',' var",
999 "var : varexp '[' expr1 ']'",
1000 "var : varexp '.' NAME",
1003 "localdeclist : NAME",
1004 "localdeclist : localdeclist ',' NAME",
1006 "decinit : '=' exprlist1",
1011 #define YYMAXDEPTH YYSTACKSIZE
1014 #define YYSTACKSIZE YYMAXDEPTH
1016 #define YYSTACKSIZE 500
1017 #define YYMAXDEPTH 500
1028 short luaY_ss
[YYSTACKSIZE
];
1029 YYSTYPE luaY_vs
[YYSTACKSIZE
];
1030 #define luaY_stacksize YYSTACKSIZE
1031 #define YYABORT goto luaY_abort
1032 #define YYREJECT goto luaY_abort
1033 #define YYACCEPT goto luaY_accept
1034 #define YYERROR goto luaY_errlab
1038 register int luaY_m
, luaY_n
, luaY_state
;
1040 register char *luaY_s
;
1041 extern char *getenv();
1043 if (luaY_s
= getenv("YYDEBUG"))
1046 if (luaY_n
>= '0' && luaY_n
<= '9')
1047 luaY_debug
= luaY_n
- '0';
1057 *luaY_ssp
= luaY_state
= 0;
1060 if (luaY_n
= luaY_defred
[luaY_state
]) goto luaY_reduce
;
1063 if ((luaY_char
= luaY_lex()) < 0) luaY_char
= 0;
1068 if (luaY_char
<= YYMAXTOKEN
) luaY_s
= luaY_name
[luaY_char
];
1069 if (!luaY_s
) luaY_s
= "illegal-symbol";
1070 printf("%sdebug: state %d, reading %d (%s)\n",
1071 YYPREFIX
, luaY_state
, luaY_char
, luaY_s
);
1075 if ((luaY_n
= luaY_sindex
[luaY_state
]) && (luaY_n
+= luaY_char
) >= 0 &&
1076 luaY_n
<= YYTABLESIZE
&& luaY_check
[luaY_n
] == luaY_char
)
1080 printf("%sdebug: state %d, shifting to state %d\n",
1081 YYPREFIX
, luaY_state
, luaY_table
[luaY_n
]);
1083 if (luaY_ssp
>= luaY_ss
+ luaY_stacksize
- 1)
1087 *++luaY_ssp
= luaY_state
= luaY_table
[luaY_n
];
1088 *++luaY_vsp
= luaY_lval
;
1090 if (luaY_errflag
> 0) --luaY_errflag
;
1093 if ((luaY_n
= luaY_rindex
[luaY_state
]) && (luaY_n
+= luaY_char
) >= 0 &&
1094 luaY_n
<= YYTABLESIZE
&& luaY_check
[luaY_n
] == luaY_char
)
1096 luaY_n
= luaY_table
[luaY_n
];
1099 if (luaY_errflag
) goto luaY_inrecovery
;
1104 luaY_error("syntax error");
1111 if (luaY_errflag
< 3)
1116 if ((luaY_n
= luaY_sindex
[*luaY_ssp
]) && (luaY_n
+= YYERRCODE
) >= 0 &&
1117 luaY_n
<= YYTABLESIZE
&& luaY_check
[luaY_n
] == YYERRCODE
)
1121 printf("%sdebug: state %d, error recovery shifting\
1122 to state %d\n", YYPREFIX
, *luaY_ssp
, luaY_table
[luaY_n
]);
1124 if (luaY_ssp
>= luaY_ss
+ luaY_stacksize
- 1)
1128 *++luaY_ssp
= luaY_state
= luaY_table
[luaY_n
];
1129 *++luaY_vsp
= luaY_lval
;
1136 printf("%sdebug: error recovery discarding state %d\n",
1137 YYPREFIX
, *luaY_ssp
);
1139 if (luaY_ssp
<= luaY_ss
) goto luaY_abort
;
1147 if (luaY_char
== 0) goto luaY_abort
;
1152 if (luaY_char
<= YYMAXTOKEN
) luaY_s
= luaY_name
[luaY_char
];
1153 if (!luaY_s
) luaY_s
= "illegal-symbol";
1154 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1155 YYPREFIX
, luaY_state
, luaY_char
, luaY_s
);
1164 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1165 YYPREFIX
, luaY_state
, luaY_n
, luaY_rule
[luaY_n
]);
1167 luaY_m
= luaY_len
[luaY_n
];
1168 luaY_val
= luaY_vsp
[1-luaY_m
];
1174 code_byte(PUSHFUNCTION
);
1175 code_code(luaY_vsp
[0].pFunc
);
1176 storesinglevar(luaY_vsp
[-1].vLong
);
1181 { luaY_val
.vLong
=luaY_vsp
[0].vLong
; init_func(); }
1186 code_constant(luaY_vsp
[0].pTStr
);
1187 luaY_val
.vLong
= 0; /* indexed variable */
1189 add_localvar(luaI_createfixedstring("self"));
1196 luaY_val
.pFunc
= new(TFunc
);
1197 luaI_initTFunc(luaY_val
.pFunc
);
1198 luaY_val
.pFunc
->size
= pc
;
1199 luaY_val
.pFunc
->code
= newvector(pc
, Byte
);
1200 luaY_val
.pFunc
->lineDefined
= luaY_vsp
[-3].vInt
;
1201 memcpy(luaY_val
.pFunc
->code
, basepc
, pc
*sizeof(Byte
));
1203 luaI_closelocalvars(luaY_val
.pFunc
);
1204 /* save func values */
1205 funcCode
= basepc
; maxcode
=maxcurr
;
1207 PrintCode(funcCode
,funcCode
+pc
);
1209 change2main(); /* change back to main code */
1214 { codeIf(luaY_vsp
[-4].vLong
, luaY_vsp
[-2].vLong
); }
1218 {luaY_val
.vLong
=pc
;}
1223 basepc
[luaY_vsp
[-3].vLong
] = IFFJMP
;
1224 code_word_at(basepc
+luaY_vsp
[-3].vLong
+1, pc
- (luaY_vsp
[-3].vLong
+ sizeof(Word
)+1));
1225 basepc
[luaY_vsp
[-1].vLong
] = UPJMP
;
1226 code_word_at(basepc
+luaY_vsp
[-1].vLong
+1, pc
- (luaY_vsp
[-6].vLong
));
1231 {luaY_val
.vLong
=pc
;}
1236 basepc
[luaY_vsp
[0].vLong
] = IFFUPJMP
;
1237 code_word_at(basepc
+luaY_vsp
[0].vLong
+1, pc
- (luaY_vsp
[-4].vLong
));
1245 adjust_mult_assign(nvarbuffer
, luaY_vsp
[0].vLong
, luaY_vsp
[-2].vInt
* 2 + nvarbuffer
);
1246 for (i
=nvarbuffer
-1; i
>=0; i
--)
1248 if (luaY_vsp
[-2].vInt
> 1 || (luaY_vsp
[-2].vInt
== 1 && varbuffer
[0] != 0))
1259 { nlocalvar
+= luaY_vsp
[-1].vInt
;
1260 adjust_mult_assign(luaY_vsp
[-1].vInt
, luaY_vsp
[0].vInt
, 0);
1265 { codeIf(luaY_vsp
[-3].vLong
, luaY_vsp
[-1].vLong
); }
1269 {luaY_val
.vInt
= nlocalvar
;}
1274 if (nlocalvar
!= luaY_vsp
[-2].vInt
)
1277 for (; nlocalvar
> luaY_vsp
[-2].vInt
; nlocalvar
--)
1278 luaI_unregisterlocalvar(lua_linenumber
);
1280 nlocalvar
= luaY_vsp
[-2].vInt
;
1288 adjust_functioncall(luaY_vsp
[-1].vLong
, MULT_RET
);
1295 luaY_val
.vLong
= pc
;
1296 code_byte(0); /* open space */
1302 { adjust_functioncall(luaY_vsp
[0].vLong
, 1); }
1306 { luaY_val
.vLong
= luaY_vsp
[-1].vLong
; }
1310 { code_byte(EQOP
); luaY_val
.vLong
= 0; }
1314 { code_byte(LTOP
); luaY_val
.vLong
= 0; }
1318 { code_byte(GTOP
); luaY_val
.vLong
= 0; }
1322 { code_byte(EQOP
); code_byte(NOTOP
); luaY_val
.vLong
= 0; }
1326 { code_byte(LEOP
); luaY_val
.vLong
= 0; }
1330 { code_byte(GEOP
); luaY_val
.vLong
= 0; }
1334 { code_byte(ADDOP
); luaY_val
.vLong
= 0; }
1338 { code_byte(SUBOP
); luaY_val
.vLong
= 0; }
1342 { code_byte(MULTOP
); luaY_val
.vLong
= 0; }
1346 { code_byte(DIVOP
); luaY_val
.vLong
= 0; }
1350 { code_byte(POWOP
); luaY_val
.vLong
= 0; }
1354 { code_byte(CONCOP
); luaY_val
.vLong
= 0; }
1358 { code_byte(MINUSOP
); luaY_val
.vLong
= 0;}
1362 { luaY_val
.vLong
= 0; }
1366 { luaY_val
.vLong
= 0;}
1370 { code_number(luaY_vsp
[0].vFloat
); luaY_val
.vLong
= 0; }
1375 code_string(luaY_vsp
[0].vWord
);
1381 {code_byte(PUSHNIL
); luaY_val
.vLong
= 0; }
1385 { luaY_val
.vLong
= luaY_vsp
[0].vLong
; }
1389 { code_byte(NOTOP
); luaY_val
.vLong
= 0;}
1398 basepc
[luaY_vsp
[-2].vLong
] = ONFJMP
;
1399 code_word_at(basepc
+luaY_vsp
[-2].vLong
+1, pc
- (luaY_vsp
[-2].vLong
+ sizeof(Word
)+1));
1410 basepc
[luaY_vsp
[-2].vLong
] = ONTJMP
;
1411 code_word_at(basepc
+luaY_vsp
[-2].vLong
+1, pc
- (luaY_vsp
[-2].vLong
+ sizeof(Word
)+1));
1418 code_byte(CREATEARRAY
);
1419 luaY_val
.vLong
= pc
; code_word(0);
1425 code_word_at(basepc
+luaY_vsp
[-3].vLong
, luaY_vsp
[-1].vInt
);
1431 code_byte(CALLFUNC
);
1432 code_byte(luaY_vsp
[-1].vInt
+luaY_vsp
[0].vInt
);
1433 luaY_val
.vLong
= pc
;
1434 code_byte(0); /* may be modified by other rules */
1439 { luaY_val
.vInt
= 0; }
1444 code_byte(PUSHSELF
);
1445 code_word(luaI_findconstant(luaY_vsp
[0].pTStr
));
1451 { luaY_val
.vInt
= adjust_functioncall(luaY_vsp
[-1].vLong
, 1); }
1455 { luaY_val
.vInt
= 1; }
1459 { luaY_val
.vLong
= 0; }
1463 { luaY_val
.vLong
= luaY_vsp
[0].vLong
; }
1467 { if (luaY_vsp
[0].vLong
!= 0) luaY_val
.vLong
= luaY_vsp
[0].vLong
; else luaY_val
.vLong
= -1; }
1471 { luaY_val
.vLong
= adjust_functioncall(luaY_vsp
[-1].vLong
, 1); }
1476 if (luaY_vsp
[0].vLong
== 0) luaY_val
.vLong
= -(luaY_vsp
[-1].vLong
+ 1); /* -length */
1479 adjust_functioncall(luaY_vsp
[0].vLong
, luaY_vsp
[-1].vLong
);
1480 luaY_val
.vLong
= luaY_vsp
[0].vLong
;
1486 { luaY_val
.vInt
= close_parlist(0); }
1490 { luaY_val
.vInt
= close_parlist(luaY_vsp
[0].vInt
); }
1494 { luaY_val
.vInt
= luaY_vsp
[0].vInt
; }
1499 if (luaY_vsp
[-2].vInt
)
1500 lua_error("invalid parameter list");
1501 luaY_val
.vInt
= luaY_vsp
[0].vInt
;
1506 { add_localvar(luaY_vsp
[0].pTStr
); luaY_val
.vInt
= 0; }
1510 { luaY_val
.vInt
= 1; }
1514 { flush_list(luaY_vsp
[0].vInt
/FIELDS_PER_FLUSH
, luaY_vsp
[0].vInt
%FIELDS_PER_FLUSH
); }
1518 { luaY_val
.vInt
= luaY_vsp
[-2].vInt
+luaY_vsp
[0].vInt
; }
1522 { luaY_val
.vInt
= luaY_vsp
[-1].vInt
; flush_record(luaY_vsp
[-1].vInt
%FIELDS_PER_FLUSH
); }
1526 { luaY_val
.vInt
= 0; }
1530 { luaY_val
.vInt
= luaY_vsp
[0].vInt
; flush_record(luaY_vsp
[0].vInt
%FIELDS_PER_FLUSH
); }
1534 { luaY_val
.vInt
= 0; }
1538 { luaY_val
.vInt
= luaY_vsp
[-1].vInt
; }
1547 luaY_val
.vInt
=luaY_vsp
[-2].vInt
+1;
1548 if (luaY_val
.vInt
%FIELDS_PER_FLUSH
== 0) flush_record(FIELDS_PER_FLUSH
);
1553 { code_constant(luaY_vsp
[0].pTStr
); }
1557 { luaY_val
.vInt
= 0; }
1561 { luaY_val
.vInt
= luaY_vsp
[-1].vInt
; }
1570 luaY_val
.vInt
=luaY_vsp
[-2].vInt
+1;
1571 if (luaY_val
.vInt
%FIELDS_PER_FLUSH
== 0)
1572 flush_list(luaY_val
.vInt
/FIELDS_PER_FLUSH
- 1, FIELDS_PER_FLUSH
);
1579 add_varbuffer(luaY_vsp
[0].vLong
);
1580 luaY_val
.vInt
= (luaY_vsp
[0].vLong
== 0) ? 1 : 0;
1586 add_varbuffer(luaY_vsp
[0].vLong
);
1587 luaY_val
.vInt
= (luaY_vsp
[0].vLong
== 0) ? luaY_vsp
[-2].vInt
+ 1 : luaY_vsp
[-2].vInt
;
1592 { luaY_val
.vLong
= luaY_vsp
[0].vLong
; }
1597 luaY_val
.vLong
= 0; /* indexed variable */
1603 code_constant(luaY_vsp
[0].pTStr
);
1604 luaY_val
.vLong
= 0; /* indexed variable */
1610 int local
= lua_localname(luaY_vsp
[0].pTStr
);
1611 if (local
== -1) /* global var */
1612 luaY_val
.vLong
= luaI_findsymbol(luaY_vsp
[0].pTStr
)+1; /* return positive value */
1614 luaY_val
.vLong
= -(local
+1); /* return negative value */
1619 { lua_pushvar(luaY_vsp
[0].vLong
); }
1623 {store_localvar(luaY_vsp
[0].pTStr
, 0); luaY_val
.vInt
= 1;}
1628 store_localvar(luaY_vsp
[0].pTStr
, luaY_vsp
[-2].vInt
);
1629 luaY_val
.vInt
= luaY_vsp
[-2].vInt
+1;
1634 { luaY_val
.vInt
= 0; }
1638 { luaY_val
.vInt
= luaY_vsp
[0].vLong
; }
1640 #line 1641 "y.tab.c"
1643 luaY_state
= *luaY_ssp
;
1645 luaY_m
= luaY_lhs
[luaY_n
];
1646 if (luaY_state
== 0 && luaY_m
== 0)
1650 printf("%sdebug: after reduction, shifting from state 0 to\
1651 state %d\n", YYPREFIX
, YYFINAL
);
1653 luaY_state
= YYFINAL
;
1654 *++luaY_ssp
= YYFINAL
;
1655 *++luaY_vsp
= luaY_val
;
1658 if ((luaY_char
= luaY_lex()) < 0) luaY_char
= 0;
1663 if (luaY_char
<= YYMAXTOKEN
) luaY_s
= luaY_name
[luaY_char
];
1664 if (!luaY_s
) luaY_s
= "illegal-symbol";
1665 printf("%sdebug: state %d, reading %d (%s)\n",
1666 YYPREFIX
, YYFINAL
, luaY_char
, luaY_s
);
1670 if (luaY_char
== 0) goto luaY_accept
;
1673 if ((luaY_n
= luaY_gindex
[luaY_m
]) && (luaY_n
+= luaY_state
) >= 0 &&
1674 luaY_n
<= YYTABLESIZE
&& luaY_check
[luaY_n
] == luaY_state
)
1675 luaY_state
= luaY_table
[luaY_n
];
1677 luaY_state
= luaY_dgoto
[luaY_m
];
1680 printf("%sdebug: after reduction, shifting from state %d \
1681 to state %d\n", YYPREFIX
, *luaY_ssp
, luaY_state
);
1683 if (luaY_ssp
>= luaY_ss
+ luaY_stacksize
- 1)
1687 *++luaY_ssp
= luaY_state
;
1688 *++luaY_vsp
= luaY_val
;
1691 luaY_error("yacc stack overflow");