diff options
| author | Lua Team <team@lua.org> | 1995-11-28 12:00:00 +0000 |
|---|---|---|
| committer | repogen <> | 1995-11-28 12:00:00 +0000 |
| commit | 71754d2f6423fb9b6e87658e58bafc5470d53f65 (patch) | |
| tree | c704e97b80e52a52d3152738941bb4c8ca676b97 /src/parser.c | |
| parent | a8b6ba0954edb9e0e669e1f451b9a8f145ce5166 (diff) | |
| download | lua-github-2.2.tar.gz | |
Lua 2.22.2
Diffstat (limited to 'src/parser.c')
| -rw-r--r-- | src/parser.c | 1058 |
1 files changed, 534 insertions, 524 deletions
diff --git a/src/parser.c b/src/parser.c index 47b77fb0..6b0dba94 100644 --- a/src/parser.c +++ b/src/parser.c @@ -13,7 +13,7 @@ # line 2 "lua.stx" -char *rcs_luastx = "$Id: lua.stx,v 3.17 1995/01/13 22:11:12 roberto Exp $"; +char *rcs_luastx = "$Id: lua.stx,v 3.25 1995/10/26 17:02:50 roberto Exp $"; #include <stdio.h> #include <stdlib.h> @@ -26,6 +26,7 @@ char *rcs_luastx = "$Id: lua.stx,v 3.17 1995/01/13 22:11:12 roberto Exp $"; #include "tree.h" #include "table.h" #include "lua.h" +#include "func.h" /* to avoid warnings generated by yacc */ int yyparse (void); @@ -49,12 +50,14 @@ static Byte *basepc; static int maincode; static int pc; + #define MAXVAR 32 static Long varbuffer[MAXVAR]; /* variables in an assignment list; it's long to store negative Word values */ static int nvarbuffer=0; /* number of variables at a list */ -static Word localvar[STACKGAP]; /* store local variable names */ +#define MAXLOCALS 32 +static Word localvar[MAXLOCALS]; /* store local variable names */ static int nlocalvar=0; /* number of local variables */ #define MAXFIELDS FIELDS_PER_FLUSH*2 @@ -64,6 +67,14 @@ static int nfields=0; /* Internal functions */ +static void yyerror (char *s) +{ + static char msg[256]; + sprintf (msg,"%s near \"%s\" at line %d in file `%s'", + s, lua_lasttext (), lua_linenumber, lua_parsedfile); + lua_error (msg); +} + static void code_byte (Byte c) { if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */ @@ -96,10 +107,10 @@ static void code_float (float n) code_byte(code.m.c4); } -static void code_code (Byte *b) +static void code_code (TFunc *tf) { CodeCode code; - code.b = b; + code.tf = tf; code_byte(code.m.c1); code_byte(code.m.c2); code_byte(code.m.c3); @@ -116,10 +127,10 @@ static void code_word_at (Byte *p, Word n) static void push_field (Word name) { - if (nfields < STACKGAP-1) + if (nfields < MAXFIELDS) fields[nfields++] = name; else - lua_error ("too many fields in a constructor"); + lua_error ("too many fields in nested constructors"); } static void flush_record (int n) @@ -148,18 +159,26 @@ static void flush_list (int m, int n) code_byte(n); } -static void add_nlocalvar (int n) +static void add_localvar (Word name) { - if (MAX_TEMPS+nlocalvar+MAXVAR+n < STACKGAP) - nlocalvar += n; + if (nlocalvar < MAXLOCALS) + localvar[nlocalvar++] = name; else lua_error ("too many local variables"); } -static void incr_nvarbuffer (void) +static void store_localvar (Word name, int n) { - if (nvarbuffer < MAXVAR-1) - nvarbuffer++; + if (nlocalvar+n < MAXLOCALS) + localvar[nlocalvar+n] = name; + else + lua_error ("too many local variables"); +} + +static void add_varbuffer (Long var) +{ + if (nvarbuffer < MAXVAR) + varbuffer[nvarbuffer++] = var; else lua_error ("variable buffer overflow"); } @@ -238,26 +257,35 @@ static void lua_codeadjust (int n) } } -static void init_function (TreeNode *func) +static void change2main (void) { - if (funcCode == NULL) /* first function */ - { - funcCode = newvector(CODE_BLOCK, Byte); - maxcode = CODE_BLOCK; - } - pc=0; basepc=funcCode; maxcurr=maxcode; - nlocalvar=0; - if (lua_debug) + /* (re)store main values */ + pc=maincode; basepc=*initcode; maxcurr=maxmain; + nlocalvar=0; +} + +static void savemain (void) +{ + /* save main values */ + maincode=pc; *initcode=basepc; maxmain=maxcurr; +} + +static void init_func (void) +{ + if (funcCode == NULL) /* first function */ { - code_byte(SETFUNCTION); - code_code((Byte *)luaI_strdup(lua_file[lua_nfile-1])); - code_word(luaI_findconstant(func)); + funcCode = newvector(CODE_BLOCK, Byte); + maxcode = CODE_BLOCK; } + savemain(); /* save main values */ + /* set func values */ + pc=0; basepc=funcCode; maxcurr=maxcode; + nlocalvar = 0; + luaI_codedebugline(lua_linenumber); } static void codereturn (void) { - if (lua_debug) code_byte(RESET); if (nlocalvar == 0) code_byte(RETCODE0); else @@ -267,49 +295,71 @@ static void codereturn (void) } } -static void codedebugline (void) +void luaI_codedebugline (int line) { - if (lua_debug) + static int lastline = 0; + if (lua_debug && line != lastline) { code_byte(SETLINE); - code_word(lua_linenumber); + code_word(line); + lastline = line; } } -static void adjust_mult_assign (int vars, int exps, int temps) +static int adjust_functioncall (Long exp, int i) { - if (exps < 0) + if (exp <= 0) + return -exp; /* exp is -list length */ + else { - int r = vars - (-exps-1); - if (r >= 0) - code_byte(r); + int temp = basepc[exp]; + basepc[exp] = i; + return temp+i; + } +} + +static void adjust_mult_assign (int vars, Long exps, int temps) +{ + if (exps > 0) + { /* must correct function call */ + int diff = vars - basepc[exps]; + if (diff >= 0) + adjust_functioncall(exps, diff); else { - code_byte(0); + adjust_functioncall(exps, 0); lua_codeadjust(temps); } } - else if (vars != exps) + else if (vars != -exps) lua_codeadjust(temps); } -static void lua_codestore (int i) +static void storesinglevar (Long v) { - if (varbuffer[i] > 0) /* global var */ + if (v > 0) /* global var */ { - code_byte(STOREGLOBAL); - code_word(varbuffer[i]-1); + code_byte(STOREGLOBAL); + code_word(v-1); } - else if (varbuffer[i] < 0) /* local var */ + else if (v < 0) /* local var */ { - int number = (-varbuffer[i]) - 1; - if (number < 10) code_byte(STORELOCAL0 + number); - else - { - code_byte(STORELOCAL); - code_byte(number); - } + int number = (-v) - 1; + if (number < 10) code_byte(STORELOCAL0 + number); + else + { + code_byte(STORELOCAL); + code_byte(number); + } } + else + code_byte(STOREINDEXED0); +} + +static void lua_codestore (int i) +{ + if (varbuffer[i] != 0) /* global or local var */ + storesinglevar(varbuffer[i]); else /* indexed var */ { int j; @@ -345,26 +395,22 @@ static void codeIf (Long thenAdd, Long elseAdd) code_word_at(basepc+thenAdd+1,elseinit-(thenAdd+sizeof(Word)+1)); } -static void yyerror (char *s) -{ - static char msg[256]; - sprintf (msg,"%s near \"%s\" at line %d in file \"%s\"", - s, lua_lasttext (), lua_linenumber, lua_filename()); - lua_error (msg); -} - /* ** Parse LUA code. */ -void lua_parse (Byte **code) +void lua_parse (TFunc *tf) { - initcode = code; + lua_debug = 0; + initcode = &(tf->code); *initcode = newvector(CODE_BLOCK, Byte); maincode = 0; maxmain = CODE_BLOCK; + change2main(); if (yyparse ()) lua_error("parse error"); + savemain(); (*initcode)[maincode++] = RETCODE0; + tf->size = maincode; #if LISTING { static void PrintCode (Byte *c, Byte *end); PrintCode(*initcode,*initcode+maincode); } @@ -373,7 +419,7 @@ void lua_parse (Byte **code) -# line 365 "lua.stx" +# line 411 "lua.stx" typedef union { int vInt; @@ -381,7 +427,7 @@ typedef union char *pChar; Word vWord; Long vLong; - Byte *pByte; + TFunc *pFunc; TreeNode *pNode; } YYSTYPE; # define WRONGTOKEN 257 @@ -421,7 +467,7 @@ extern int yyerrflag; YYSTYPE yylval, yyval; # define YYERRCODE 256 -# line 737 "lua.stx" +# line 789 "lua.stx" #if LISTING @@ -476,7 +522,7 @@ static void PrintCode (Byte *code, Byte *end) int n = p-code; p++; get_code(c,p); - printf ("%d PUSHFUNCTION %p\n", n, c.b); + printf ("%d PUSHFUNCTION %p\n", n, c.tf); } break; @@ -632,17 +678,6 @@ static void PrintCode (Byte *code, Byte *end) printf ("%d RETCODE %d\n", p-code, *(++p)); p++; break; - case SETFUNCTION: - { - CodeCode c1; - CodeWord c2; - int n = p-code; - p++; - get_code(c1,p); - get_word(c2,p); - printf ("%d SETFUNCTION %s %d\n", n, (char *)c1.b, c2.w); - } - break; case SETLINE: { CodeWord c; @@ -653,7 +688,6 @@ static void PrintCode (Byte *code, Byte *end) } break; - case RESET: printf ("%d RESET\n", (p++)-code); break; default: printf ("%d Cannot happen: code %d\n", (p++)-code, *(p-1)); break; } } @@ -663,203 +697,194 @@ static void PrintCode (Byte *code, Byte *end) int yyexca[] ={ -1, 1, 0, -1, - -2, 2, --1, 20, - 61, 91, - 44, 91, - -2, 97, --1, 32, - 40, 66, - 123, 66, - -2, 53, --1, 47, - 123, 63, - -2, 70, --1, 74, - 125, 79, + -2, 0, +-1, 14, + 61, 88, + 44, 88, + -2, 94, +-1, 22, + 40, 7, + -2, 94, +-1, 29, + 40, 59, + 123, 59, + -2, 46, +-1, 44, + 123, 56, -2, 63, --1, 79, - 275, 37, - 276, 37, - 277, 37, - 278, 37, - 62, 37, - 60, 37, - 279, 37, - 280, 37, - 281, 37, - 43, 37, - 45, 37, - 42, 37, - 47, 37, - 94, 37, - -2, 72, --1, 80, - 91, 97, - 46, 97, - -2, 92, --1, 118, - 261, 33, - 262, 33, - 266, 33, - 267, 33, - -2, 16, --1, 133, - 125, 85, +-1, 71, + 123, 56, + -2, 84, +-1, 76, + 275, 30, + 276, 30, + 277, 30, + 278, 30, + 62, 30, + 60, 30, + 279, 30, + 280, 30, + 281, 30, + 43, 30, + 45, 30, + 42, 30, + 47, 30, + 94, 30, + -2, 65, +-1, 77, + 91, 94, + 46, 94, + -2, 89, +-1, 132, + 123, 56, + -2, 78, +-1, 138, + 123, 56, -2, 63, --1, 158, - 123, 63, - -2, 70, --1, 159, - 275, 37, - 276, 37, - 277, 37, - 278, 37, - 62, 37, - 60, 37, - 279, 37, - 280, 37, - 281, 37, - 43, 37, - 45, 37, - 42, 37, - 47, 37, - 94, 37, - -2, 74, +-1, 155, + 275, 30, + 276, 30, + 277, 30, + 278, 30, + 62, 30, + 60, 30, + 279, 30, + 280, 30, + 281, 30, + 43, 30, + 45, 30, + 42, 30, + 47, 30, + 94, 30, + -2, 67, }; -# define YYNPROD 103 -# define YYLAST 351 +# define YYNPROD 100 +# define YYLAST 311 int yyact[]={ - 64, 62, 6, 63, 152, 65, 7, 64, 62, 145, - 63, 120, 65, 92, 64, 62, 89, 63, 57, 65, - 58, 64, 62, 87, 63, 57, 65, 58, 64, 62, - 24, 63, 57, 65, 58, 64, 62, 54, 63, 57, - 65, 58, 45, 10, 29, 142, 57, 171, 58, 30, - 29, 123, 66, 167, 14, 30, 160, 117, 15, 66, - 16, 162, 163, 173, 19, 131, 66, 138, 24, 28, - 112, 114, 130, 66, 74, 71, 8, 64, 66, 52, - 66, 86, 65, 51, 161, 83, 51, 66, 43, 136, - 27, 12, 64, 62, 26, 63, 133, 65, 49, 70, - 135, 119, 84, 125, 124, 42, 72, 122, 109, 32, - 53, 132, 79, 73, 85, 39, 75, 79, 47, 23, - 149, 91, 143, 31, 78, 20, 88, 38, 50, 66, - 11, 50, 95, 96, 97, 98, 99, 100, 101, 102, - 103, 104, 105, 106, 66, 48, 36, 129, 128, 158, - 113, 141, 94, 81, 79, 77, 18, 41, 40, 80, - 139, 13, 9, 118, 90, 93, 121, 25, 5, 4, - 3, 2, 22, 126, 111, 76, 82, 44, 134, 110, - 21, 46, 17, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 140, 0, 0, 0, 0, - 0, 0, 0, 0, 147, 148, 0, 151, 0, 150, - 0, 0, 153, 159, 0, 156, 0, 0, 0, 0, - 164, 107, 108, 0, 0, 0, 0, 0, 79, 116, - 170, 169, 55, 68, 69, 56, 59, 60, 61, 67, - 68, 69, 56, 59, 60, 61, 67, 68, 69, 56, - 59, 60, 61, 67, 68, 69, 56, 59, 60, 61, - 67, 177, 35, 56, 59, 60, 61, 67, 35, 137, - 127, 157, 0, 166, 67, 33, 34, 24, 0, 0, - 146, 33, 34, 115, 0, 0, 0, 37, 0, 0, - 0, 155, 0, 37, 0, 0, 0, 172, 0, 0, - 144, 0, 0, 0, 0, 0, 0, 165, 0, 0, - 0, 0, 0, 154, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 174, 0, 176, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 168, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 175 }; + 61, 59, 148, 60, 141, 62, 118, 61, 59, 90, + 60, 89, 62, 86, 84, 18, 42, 168, 54, 164, + 55, 61, 59, 156, 60, 54, 62, 55, 61, 59, + 115, 60, 73, 62, 157, 61, 59, 19, 60, 54, + 62, 55, 61, 59, 82, 60, 54, 62, 55, 158, + 159, 129, 63, 54, 91, 55, 111, 25, 121, 63, + 54, 109, 55, 127, 26, 61, 59, 26, 60, 27, + 62, 7, 27, 63, 71, 8, 33, 9, 11, 63, + 63, 12, 6, 80, 67, 18, 13, 63, 68, 7, + 48, 40, 4, 8, 63, 9, 24, 76, 138, 12, + 81, 133, 76, 18, 61, 59, 61, 60, 39, 62, + 20, 62, 146, 130, 117, 132, 69, 63, 123, 48, + 104, 105, 122, 70, 124, 120, 72, 106, 48, 50, + 29, 46, 17, 44, 128, 47, 85, 23, 83, 76, + 51, 28, 92, 93, 94, 95, 96, 97, 98, 99, + 100, 101, 102, 103, 88, 140, 63, 45, 63, 36, + 112, 14, 131, 139, 47, 35, 22, 151, 126, 134, + 125, 78, 137, 47, 153, 74, 38, 37, 75, 142, + 116, 5, 3, 154, 2, 49, 21, 147, 16, 87, + 152, 165, 163, 11, 110, 108, 76, 155, 145, 160, + 77, 79, 41, 171, 135, 107, 162, 173, 161, 136, + 15, 43, 10, 167, 143, 144, 1, 0, 169, 0, + 119, 149, 150, 0, 170, 0, 172, 0, 0, 0, + 0, 0, 0, 65, 66, 53, 56, 57, 58, 64, + 65, 66, 53, 56, 57, 58, 64, 17, 166, 0, + 114, 0, 0, 52, 65, 66, 53, 56, 57, 58, + 64, 65, 66, 53, 56, 57, 58, 64, 65, 66, + 53, 56, 57, 58, 64, 0, 14, 53, 56, 57, + 58, 64, 32, 0, 0, 32, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 30, 31, 18, 30, 31, + 113, 0, 0, 0, 64, 0, 0, 34, 0, 0, + 34 }; int yypact[]={ - -1000, -268, -1000, -1000, -1000, -1000, -230, -1000, 32, -205, - 36, -1000, -1000, -1000, 4, -1000, -1000, 44, -1000, -231, - -1000, 78, -1000, 40, -1000, 70, -236, -28, -1000, 4, - 4, -1000, 40, -1000, -1000, -1000, -1000, 4, -49, -1000, - 4, -1000, 4, -243, 41, -1000, -1000, 4, -1000, -250, - 4, -257, -1000, -260, -1000, -1000, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, -1000, -1000, - 67, -21, -16, -16, 10, -35, -209, -1000, 57, -1000, - -1000, 37, -1000, -262, 4, 66, 57, -1000, -42, -1000, - 63, 59, -1000, 70, -1000, -7, -7, -7, -7, -7, - -7, 35, 35, -16, -16, -16, 50, -1000, -1000, -1000, - -53, 52, 56, -21, -1000, 28, -1000, -1000, -223, -1000, - -1000, 57, -1000, -1000, -1000, -264, -1000, -1000, 4, 4, - -1000, -1000, -1000, 4, -1000, -269, 4, -1000, -1000, 4, - 32, -1000, -1000, 4, -211, -1000, -200, -14, -14, -269, - -21, -1000, 28, -21, -1000, -1000, -21, -1000, 4, -1000, - -1000, -214, -1000, -1000, 56, -220, 32, -1000, -1000, -197, - -1000, -1000, -1000, -1000, -1000, -1000, -200, -1000 }; + -1000, -188, -1000, -1000, 51, -1000, -258, 24, -1000, -1000, + 47, -1000, -257, -1000, -1000, 93, -1000, 73, -1000, -1000, + -1000, 89, -1000, 82, -7, -1000, 24, 24, -1000, 73, + -1000, -1000, -1000, -1000, 24, -49, -1000, 24, -1000, 24, + -258, 39, -1000, -1000, 24, -1000, -259, 24, -260, -1000, + -262, -264, -1000, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, -1000, -1000, 86, -21, -15, + -15, 27, -14, -236, -1000, 70, -1000, -1000, 44, -1000, + -267, 24, 84, 70, -1000, -35, -1000, 81, 74, -1000, + -1000, -1000, 23, 23, 23, 23, 23, 23, 64, 64, + -15, -15, -15, 62, -1000, -1000, -1000, -62, -1000, 69, + 71, -1000, -21, 40, -1000, 24, -170, -1000, -1000, 70, + -1000, -1000, -1000, -269, -1000, 24, 24, -1000, 53, -1000, + -271, -1000, 24, 24, -1000, -21, 51, -1000, 24, 24, + -244, -1000, -212, 0, 0, -1000, -271, -1000, 40, -21, + -21, -1000, -1000, -1000, 51, -1000, -1000, -248, -1000, 24, + -1000, 69, -250, -1000, -1000, -1000, -42, -1000, -1000, -1000, + -1000, -1000, -212, -1000 }; int yypgo[]={ - 0, 183, 152, 69, 114, 81, 182, 181, 180, 179, - 177, 176, 70, 174, 115, 172, 79, 171, 76, 130, - 170, 169, 168, 167, 165, 164, 175, 163, 162, 161, - 67, 160, 75, 84, 158, 157, 146, 155, 151, 149, - 123, 109, 148, 147, 127, 122, 121, 65, 120, 71 }; + 0, 216, 54, 44, 138, 76, 57, 212, 211, 210, + 205, 202, 201, 199, 61, 198, 195, 194, 189, 159, + 188, 186, 185, 184, 182, 92, 37, 181, 130, 32, + 180, 88, 34, 177, 176, 175, 172, 141, 170, 168, + 165, 163, 154, 134, 51, 56 }; int yyr1[]={ - 0, 1, 17, 1, 1, 1, 1, 23, 20, 24, - 21, 16, 27, 27, 19, 19, 28, 18, 31, 30, - 29, 34, 29, 35, 29, 29, 29, 29, 33, 33, - 33, 37, 26, 38, 39, 38, 2, 32, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 42, - 3, 43, 3, 44, 40, 36, 8, 8, 7, 7, - 4, 4, 5, 45, 5, 25, 25, 46, 46, 9, - 9, 9, 48, 9, 47, 47, 12, 12, 49, 13, - 13, 6, 6, 14, 14, 14, 15, 41, 10, 10, - 11, 11, 22 }; + 0, 1, 1, 1, 23, 23, 24, 21, 21, 22, + 30, 30, 26, 26, 25, 33, 25, 34, 25, 25, + 25, 25, 32, 32, 32, 35, 29, 36, 36, 2, + 31, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 38, 6, 39, 6, 40, 37, 5, 9, + 9, 8, 8, 3, 3, 4, 41, 4, 18, 18, + 42, 42, 43, 10, 10, 15, 15, 44, 44, 13, + 13, 14, 14, 45, 16, 16, 17, 17, 7, 7, + 19, 19, 19, 20, 28, 11, 11, 12, 12, 27 }; int yyr2[]={ - 0, 0, 1, 9, 4, 4, 4, 1, 9, 1, - 13, 11, 0, 6, 0, 2, 1, 4, 1, 4, - 17, 1, 17, 1, 13, 7, 3, 7, 0, 4, - 15, 1, 7, 0, 1, 9, 1, 3, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 5, 3, 3, 3, 3, 3, 3, 5, 1, - 11, 1, 11, 1, 9, 5, 3, 7, 7, 3, - 1, 3, 3, 1, 9, 1, 3, 3, 7, 1, - 5, 5, 1, 11, 0, 2, 3, 7, 7, 3, - 7, 3, 7, 3, 9, 7, 3, 3, 3, 7, - 1, 5, 3 }; + 0, 0, 4, 4, 4, 2, 7, 3, 7, 11, + 0, 6, 0, 2, 17, 1, 17, 1, 13, 7, + 2, 7, 0, 4, 15, 1, 7, 0, 7, 1, + 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 5, 3, 3, 3, 3, 3, + 3, 5, 1, 11, 1, 11, 1, 9, 5, 3, + 7, 7, 3, 1, 3, 3, 1, 9, 1, 3, + 3, 7, 1, 7, 5, 1, 5, 0, 2, 1, + 5, 3, 7, 7, 1, 5, 3, 7, 3, 7, + 3, 9, 7, 3, 3, 3, 7, 1, 5, 3 }; int yychk[]={ - -1000, -1, -17, -20, -21, -22, 270, 274, -18, -28, - 273, -19, 59, -29, 259, 263, 265, -6, -36, 269, - -14, -8, -15, -41, 273, -23, 58, -32, -3, 40, - 45, -40, -41, 271, 272, 258, -36, 283, -44, -14, - -34, -35, 61, 44, -10, 273, -7, 40, -40, 58, - 91, 46, -16, 40, 273, 260, 277, 60, 62, 278, - 279, 280, 43, 45, 42, 47, 94, 281, 275, 276, - -3, -32, -32, -32, 123, -32, -26, -37, -5, -3, - -14, -41, -11, 44, 61, -4, -5, 273, -32, 273, - -25, -46, 273, -24, -2, -32, -32, -32, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -2, -2, 41, - -9, -13, -12, -32, -49, 273, 264, 266, -27, 44, - 273, -5, 41, 93, 41, 44, -16, -26, -42, -43, - 125, -47, 59, 44, -47, 44, 61, -2, -30, -31, - -18, -38, 268, -45, -26, 273, -2, -32, -32, -48, - -32, -49, 273, -32, -26, -2, -32, -19, -39, -3, - 267, -33, 261, 262, -12, -2, -4, 267, -26, -30, - -47, 267, -19, 260, -2, -26, -2, -33 }; + -1000, -1, -23, -24, -25, -27, 270, 259, 263, 265, + -7, -5, 269, 274, -19, -9, -20, -28, 273, -26, + 59, -21, -19, -28, -31, -6, 40, 45, -37, -28, + 271, 272, 258, -5, 283, -40, -19, -33, -34, 61, + 44, -11, 273, -8, 40, -37, 58, 91, 46, -22, + 40, 58, 260, 277, 60, 62, 278, 279, 280, 43, + 45, 42, 47, 94, 281, 275, 276, -6, -31, -31, + -31, 123, -31, -29, -35, -4, -6, -19, -28, -12, + 44, 61, -3, -4, 273, -31, 273, -18, -42, 273, + 273, -2, -31, -31, -31, -31, -31, -31, -31, -31, + -31, -31, -31, -31, -2, -2, 41, -10, -16, -14, + -17, -45, -31, 273, 264, 266, -30, 44, 273, -4, + 41, 93, 41, 44, -29, -38, -39, 125, -43, -44, + 44, -44, 44, 61, -2, -31, -25, -36, 268, -41, + -29, 273, -2, -31, -31, -15, 59, -45, 273, -31, + -31, -29, -2, -26, -3, -6, 267, -32, 261, 262, + -13, -14, -2, -26, 267, -29, -31, -44, 267, 260, + -2, -29, -2, -32 }; int yydef[]={ - 1, -2, 16, 4, 5, 6, 0, 102, 14, 0, - 7, 3, 15, 17, 63, 21, 23, 0, 26, 0, - -2, 63, 93, 66, 96, 0, 0, 0, 37, 63, - 63, 52, -2, 54, 55, 56, 57, 63, 0, 97, - 63, 31, 63, 0, 100, 98, 65, -2, 69, 0, - 63, 0, 8, 75, 9, 36, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 36, 36, - 37, 0, 51, 58, -2, 0, 0, 12, 25, -2, - -2, 0, 27, 0, 63, 0, 71, 67, 0, 95, - 0, 76, 77, 0, 31, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 50, 59, 61, 38, - 0, 84, 84, 89, 86, 96, 36, 18, -2, 73, - 99, 101, 68, 94, 31, 0, 10, 36, 63, 63, - 64, 80, 82, -2, 81, 85, 63, 31, 36, 63, - 14, 32, 34, 63, 0, 78, 28, 60, 62, 0, - 90, 87, 0, 88, 36, 24, 19, 13, -2, -2, - 11, 0, 31, 18, 84, 0, 14, 20, 29, 0, - 83, 22, 35, 36, 31, 36, 28, 30 }; + 1, -2, 2, 3, 12, 5, 0, 56, 15, 17, + 0, 20, 0, 99, -2, 56, 90, 59, 93, 4, + 13, 0, -2, 0, 0, 30, 56, 56, 45, -2, + 47, 48, 49, 50, 56, 0, 94, 56, 25, 56, + 0, 97, 95, 58, -2, 62, 0, 56, 0, 6, + 68, 0, 29, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 29, 29, 30, 0, 44, + 51, -2, 0, 0, 10, 19, -2, -2, 0, 21, + 0, 56, 0, 64, 60, 0, 92, 0, 69, 70, + 8, 25, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 52, 54, 31, 0, 72, 77, + 77, 81, 86, 93, 29, 56, 27, 66, 96, 98, + 61, 91, 25, 0, 29, 56, 56, 57, 75, 74, + 78, 85, -2, 56, 25, 29, 12, 26, -2, 56, + 0, 71, 22, 53, 55, 73, 79, 82, 0, 87, + 83, 29, 18, 11, 12, -2, 9, 0, 25, 56, + 76, 77, 0, 28, 14, 23, 0, 80, 16, 29, + 25, 29, 22, 24 }; typedef struct { char *t_name; int t_val; } yytoktype; #ifndef YYDEBUG # define YYDEBUG 0 /* don't allow debugging */ @@ -910,39 +935,32 @@ char * yyreds[] = { "-no such reduction-", "functionlist : /* empty */", - "functionlist : functionlist", - "functionlist : functionlist stat sc", + "functionlist : functionlist globalstat", "functionlist : functionlist function", - "functionlist : functionlist method", - "functionlist : functionlist setdebug", - "function : FUNCTION NAME", - "function : FUNCTION NAME body", - "method : FUNCTION NAME ':' NAME", - "method : FUNCTION NAME ':' NAME body", + "globalstat : stat sc", + "globalstat : setdebug", + "function : FUNCTION funcname body", + "funcname : var", + "funcname : varexp ':' NAME", "body : '(' parlist ')' block END", "statlist : /* empty */", "statlist : statlist stat sc", "sc : /* empty */", "sc : ';'", - "stat : /* empty */", - "stat : stat1", - "cond : /* empty */", - "cond : expr1", - "stat1 : IF expr1 THEN PrepJump block PrepJump elsepart END", - "stat1 : WHILE", - "stat1 : WHILE expr1 DO PrepJump block PrepJump END", - "stat1 : REPEAT", - "stat1 : REPEAT block UNTIL cond PrepJump", - "stat1 : varlist1 '=' exprlist1", - "stat1 : functioncall", - "stat1 : LOCAL localdeclist decinit", + "stat : IF expr1 THEN PrepJump block PrepJump elsepart END", + "stat : WHILE", + "stat : WHILE expr1 DO PrepJump block PrepJump END", + "stat : REPEAT", + "stat : REPEAT block UNTIL expr1 PrepJump", + "stat : varlist1 '=' exprlist1", + "stat : functioncall", + "stat : LOCAL localdeclist decinit", "elsepart : /* empty */", "elsepart : ELSE block", - "elsepart : ELSEIF cond THEN PrepJump block PrepJump elsepart", + "elsepart : ELSEIF expr1 THEN PrepJump block PrepJump elsepart", "block : /* empty */", "block : statlist ret", "ret : /* empty */", - "ret : RETURN", "ret : RETURN exprlist sc", "PrepJump : /* empty */", "expr1 : expr", @@ -987,16 +1005,20 @@ char * yyreds[] = "parlist : parlist1", "parlist1 : NAME", "parlist1 : parlist1 ',' NAME", - "fieldlist : /* empty */", - "fieldlist : lfieldlist1 lastcomma", + "fieldlist : lfieldlist", + "fieldlist : lfieldlist semicolonpart", "fieldlist : ffieldlist1 lastcomma", - "fieldlist : lfieldlist1 ';'", - "fieldlist : lfieldlist1 ';' ffieldlist1 lastcomma", + "semicolonpart : /* empty */", + "semicolonpart : ';' ffieldlist", "lastcomma : /* empty */", "lastcomma : ','", + "ffieldlist : /* empty */", + "ffieldlist : ffieldlist1 lastcomma", "ffieldlist1 : ffield", "ffieldlist1 : ffieldlist1 ',' ffield", "ffield : NAME '=' expr1", + "lfieldlist : /* empty */", + "lfieldlist : lfieldlist1 lastcomma", "lfieldlist1 : expr1", "lfieldlist1 : lfieldlist1 ',' expr1", "varlist1 : var", @@ -1507,118 +1529,90 @@ $vars */ switch( yytmp ) { -case 2: -# line 411 "lua.stx" -{ - pc=maincode; basepc=*initcode; maxcurr=maxmain; - nlocalvar=0; - } break; -case 3: -# line 416 "lua.stx" -{ - maincode=pc; *initcode=basepc; maxmain=maxcurr; - } break; -case 7: -# line 425 "lua.stx" -{ - init_function(yypvt[-0].pNode); - } break; -case 8: -# line 429 "lua.stx" +case 6: +# line 470 "lua.stx" { - Word func = luaI_findsymbol(yypvt[-2].pNode); - s_tag(func) = LUA_T_FUNCTION; - s_bvalue(func) = yypvt[-0].pByte; + code_byte(PUSHFUNCTION); + code_code(yypvt[-0].pFunc); + storesinglevar(yypvt[-1].vLong); } break; -case 9: -# line 437 "lua.stx" -{ - init_function(yypvt[-0].pNode); - localvar[nlocalvar]=luaI_findsymbolbyname("self"); - add_nlocalvar(1); - } break; -case 10: -# line 443 "lua.stx" +case 7: +# line 477 "lua.stx" +{ yyval.vLong =yypvt[-0].vLong; init_func(); } break; +case 8: +# line 479 "lua.stx" { - /* assign function to table field */ - pc=maincode; basepc=*initcode; maxcurr=maxmain; - nlocalvar=0; - lua_pushvar(luaI_findsymbol(yypvt[-4].pNode)+1); - code_byte(PUSHSTRING); - code_word(luaI_findconstant(yypvt[-2].pNode)); - code_byte(PUSHFUNCTION); - code_code(yypvt[-0].pByte); - code_byte(STOREINDEXED0); - maincode=pc; *initcode=basepc; maxmain=maxcurr; - } break; -case 11: -# line 458 "lua.stx" + code_byte(PUSHSTRING); + code_word(luaI_findconstant(yypvt[-0].pNode)); + yyval.vLong = 0; /* indexed variable */ + init_func(); + add_localvar(luaI_findsymbolbyname("self")); + } break; +case 9: +# line 489 "lua.stx" { codereturn(); - yyval.pByte = newvector(pc, Byte); - memcpy(yyval.pByte, basepc, pc*sizeof(Byte)); + yyval.pFunc = new(TFunc); + yyval.pFunc->size = pc; + yyval.pFunc->code = newvector(pc, Byte); + yyval.pFunc->fileName = lua_parsedfile; + yyval.pFunc->lineDefined = yypvt[-3].vInt; + memcpy(yyval.pFunc->code, basepc, pc*sizeof(Byte)); + /* save func values */ funcCode = basepc; maxcode=maxcurr; #if LISTING PrintCode(funcCode,funcCode+pc); #endif + change2main(); /* change back to main code */ } break; -case 16: -# line 475 "lua.stx" -{ codedebugline(); } break; -case 18: -# line 477 "lua.stx" -{ codedebugline(); } break; -case 20: -# line 480 "lua.stx" +case 14: +# line 513 "lua.stx" { codeIf(yypvt[-4].vLong, yypvt[-2].vLong); } break; -case 21: -# line 482 "lua.stx" +case 15: +# line 515 "lua.stx" {yyval.vLong=pc;} break; -case 22: -# line 483 "lua.stx" +case 16: +# line 516 "lua.stx" { basepc[yypvt[-3].vLong] = IFFJMP; code_word_at(basepc+yypvt[-3].vLong+1, pc - (yypvt[-3].vLong + sizeof(Word)+1)); basepc[yypvt[-1].vLong] = UPJMP; code_word_at(basepc+yypvt[-1].vLong+1, pc - (yypvt[-6].vLong)); } break; -case 23: -# line 490 "lua.stx" +case 17: +# line 523 "lua.stx" {yyval.vLong=pc;} break; -case 24: -# line 491 "lua.stx" +case 18: +# line 524 "lua.stx" { basepc[yypvt[-0].vLong] = IFFUPJMP; code_word_at(basepc+yypvt[-0].vLong+1, pc - (yypvt[-4].vLong)); } break; -case 25: -# line 497 "lua.stx" +case 19: +# line 530 "lua.stx" { { int i; - adjust_mult_assign(nvarbuffer, yypvt[-0].vInt, yypvt[-2].vInt * 2 + nvarbuffer); + adjust_mult_assign(nvarbuffer, yypvt[-0].vLong, yypvt[-2].vInt * 2 + nvarbuffer); for (i=nvarbuffer-1; i>=0; i--) lua_codestore (i); if (yypvt[-2].vInt > 1 || (yypvt[-2].vInt == 1 && varbuffer[0] != 0)) lua_codeadjust (0); } } break; -case 26: -# line 507 "lua.stx" -{ code_byte(0); } break; -case 27: -# line 509 "lua.stx" -{ add_nlocalvar(yypvt[-1].vInt); +case 21: +# line 542 "lua.stx" +{ nlocalvar += yypvt[-1].vInt; adjust_mult_assign(yypvt[-1].vInt, yypvt[-0].vInt, 0); - } break; -case 30: -# line 517 "lua.stx" + } break; +case 24: +# line 550 "lua.stx" { codeIf(yypvt[-3].vLong, yypvt[-1].vLong); } break; -case 31: -# line 520 "lua.stx" +case 25: +# line 553 "lua.stx" {yyval.vInt = nlocalvar;} break; -case 32: -# line 521 "lua.stx" +case 26: +# line 554 "lua.stx" { if (nlocalvar != yypvt[-2].vInt) { @@ -1626,247 +1620,263 @@ case 32: lua_codeadjust (0); } } break; -case 34: -# line 531 "lua.stx" -{ codedebugline(); } break; -case 35: -# line 532 "lua.stx" +case 28: +# line 565 "lua.stx" { - if (yypvt[-1].vInt < 0) code_byte(MULT_RET); + adjust_functioncall(yypvt[-1].vLong, MULT_RET); codereturn(); } break; -case 36: -# line 539 "lua.stx" +case 29: +# line 572 "lua.stx" { yyval.vLong = pc; code_byte(0); /* open space */ code_word (0); } break; +case 30: +# line 578 "lua.stx" +{ adjust_functioncall(yypvt[-0].vLong, 1); } break; +case 31: +# line 581 "lua.stx" +{ yyval.vLong = yypvt[-1].vLong; } break; +case 32: +# line 582 "lua.stx" +{ code_byte(EQOP); yyval.vLong = 0; } break; +case 33: +# line 583 "lua.stx" +{ code_byte(LTOP); yyval.vLong = 0; } break; +case 34: +# line 584 "lua.stx" +{ code_byte(GTOP); yyval.vLong = 0; } break; +case 35: +# line 585 "lua.stx" +{ code_byte(EQOP); code_byte(NOTOP); yyval.vLong = 0; } break; +case 36: +# line 586 "lua.stx" +{ code_byte(LEOP); yyval.vLong = 0; } break; case 37: -# line 545 "lua.stx" -{ if (yypvt[-0].vInt == 0) code_byte(1); } break; +# line 587 "lua.stx" +{ code_byte(GEOP); yyval.vLong = 0; } break; case 38: -# line 548 "lua.stx" -{ yyval.vInt = yypvt[-1].vInt; } break; +# line 588 "lua.stx" +{ code_byte(ADDOP); yyval.vLong = 0; } break; case 39: -# line 549 "lua.stx" -{ code_byte(EQOP); yyval.vInt = 1; } break; +# line 589 "lua.stx" +{ code_byte(SUBOP); yyval.vLong = 0; } break; case 40: -# line 550 "lua.stx" -{ code_byte(LTOP); yyval.vInt = 1; } break; +# line 590 "lua.stx" +{ code_byte(MULTOP); yyval.vLong = 0; } break; case 41: -# line 551 "lua.stx" -{ code_byte(GTOP); yyval.vInt = 1; } break; +# line 591 "lua.stx" +{ code_byte(DIVOP); yyval.vLong = 0; } break; case 42: -# line 552 "lua.stx" -{ code_byte(EQOP); code_byte(NOTOP); yyval.vInt = 1; } break; +# line 592 "lua.stx" +{ code_byte(POWOP); yyval.vLong = 0; } break; case 43: -# line 553 "lua.stx" -{ code_byte(LEOP); yyval.vInt = 1; } break; +# line 593 "lua.stx" +{ code_byte(CONCOP); yyval.vLong = 0; } break; case 44: -# line 554 "lua.stx" -{ code_byte(GEOP); yyval.vInt = 1; } break; +# line 594 "lua.stx" +{ code_byte(MINUSOP); yyval.vLong = 0;} break; case 45: -# line 555 "lua.stx" -{ code_byte(ADDOP); yyval.vInt = 1; } break; +# line 595 "lua.stx" +{ yyval.vLong = 0; } break; case 46: -# line 556 "lua.stx" -{ code_byte(SUBOP); yyval.vInt = 1; } break; +# line 596 "lua.stx" +{ yyval.vLong = 0;} break; case 47: -# line 557 "lua.stx" -{ code_byte(MULTOP); yyval.vInt = 1; } break; +# line 597 "lua.stx" +{ code_number(yypvt[-0].vFloat); yyval.vLong = 0; } break; case 48: -# line 558 "lua.stx" -{ code_byte(DIVOP); yyval.vInt = 1; } break; -case 49: -# line 559 "lua.stx" -{ code_byte(POWOP); yyval.vInt = 1; } break; -case 50: -# line 560 "lua.stx" -{ code_byte(CONCOP); yyval.vInt = 1; } break; -case 51: -# line 561 "lua.stx" -{ code_byte(MINUSOP); yyval.vInt = 1;} break; -case 52: -# line 562 "lua.stx" -{ yyval.vInt = 1; } break; -case 53: -# line 563 "lua.stx" -{ yyval.vInt = 1;} break; -case 54: -# line 564 "lua.stx" -{ code_number(yypvt[-0].vFloat); yyval.vInt = 1; } break; -case 55: -# line 566 "lua.stx" +# line 599 "lua.stx" { code_byte(PUSHSTRING); code_word(yypvt[-0].vWord); - yyval.vInt = 1; + yyval.vLong = 0; } break; -case 56: -# line 571 "lua.stx" -{code_byte(PUSHNIL); yyval.vInt = 1; } break; -case 57: -# line 572 "lua.stx" -{ yyval.vInt = 0; } break; -case 58: -# line 573 "lua.stx" -{ code_byte(NOTOP); yyval.vInt = 1;} break; -case 59: -# line 574 "lua.stx" +case 49: +# line 604 "lua.stx" +{code_byte(PUSHNIL); yyval.vLong = 0; } break; +case 50: +# line 605 "lua.stx" +{ yyval.vLong = yypvt[-0].vLong; } break; +case 51: +# line 606 "lua.stx" +{ code_byte(NOTOP); yyval.vLong = 0;} break; +case 52: +# line 607 "lua.stx" {code_byte(POP); } break; -case 60: -# line 575 "lua.stx" +case 53: +# line 608 "lua.stx" { basepc[yypvt[-2].vLong] = ONFJMP; code_word_at(basepc+yypvt[-2].vLong+1, pc - (yypvt[-2].vLong + sizeof(Word)+1)); - yyval.vInt = 1; + yyval.vLong = 0; } break; -case 61: -# line 580 "lua.stx" +case 54: +# line 613 "lua.stx" {code_byte(POP); } break; -case 62: -# line 581 "lua.stx" +case 55: +# line 614 "lua.stx" { basepc[yypvt[-2].vLong] = ONTJMP; code_word_at(basepc+yypvt[-2].vLong+1, pc - (yypvt[-2].vLong + sizeof(Word)+1)); - yyval.vInt = 1; + yyval.vLong = 0; } break; -case 63: -# line 589 "lua.stx" +case 56: +# line 622 "lua.stx" { code_byte(CREATEARRAY); yyval.vLong = pc; code_word(0); } break; -case 64: -# line 594 "lua.stx" +case 57: +# line 627 "lua.stx" { code_word_at(basepc+yypvt[-3].vLong, yypvt[-1].vInt); } break; -case 65: -# line 600 "lua.stx" -{ code_byte(CALLFUNC); code_byte(yypvt[-1].vInt+yypvt[-0].vInt); } break; -case 66: -# line 603 "lua.stx" +case 58: +# line 633 "lua.stx" +{ + code_byte(CALLFUNC); + code_byte(yypvt[-1].vInt+yypvt[-0].vInt); + yyval.vLong = pc; + code_byte(0); /* may be modified by other rules */ + } break; +case 59: +# line 641 "lua.stx" { yyval.vInt = 0; } break; -case 67: -# line 605 "lua.stx" +case 60: +# line 643 "lua.stx" { code_byte(PUSHSELF); code_word(luaI_findconstant(yypvt[-0].pNode)); yyval.vInt = 1; } break; +case 61: +# line 651 "lua.stx" +{ yyval.vInt = adjust_functioncall(yypvt[-1].vLong, 1); } break; +case 62: +# line 652 "lua.stx" +{ yyval.vInt = 1; } break; +case 63: +# line 655 "lua.stx" +{ yyval.vLong = 0; } break; +case 64: +# line 656 "lua.stx" +{ yyval.vLong = yypvt[-0].vLong; } break; +case 65: +# line 659 "lua.stx" +{ if (yypvt[-0].vLong != 0) yyval.vLong = yypvt[-0].vLong; else yyval.vLong = -1; } break; +case 66: +# line 660 "lua.stx" +{ yyval.vLong = adjust_functioncall(yypvt[-1].vLong, 1); } break; +case 67: +# line 661 "lua.stx" +{ + if (yypvt[-0].vLong == 0) yyval.vLong = -(yypvt[-1].vLong + 1); /* -length */ + else + { + adjust_functioncall(yypvt[-0].vLong, yypvt[-1].vLong); + yyval.vLong = yypvt[-0].vLong; + } + } break; case 68: -# line 613 "lua.stx" -{ if (yypvt[-1].vInt<0) { code_byte(1); yyval.vInt = -yypvt[-1].vInt; } else yyval.vInt = yypvt[-1].vInt; } break; +# line 671 "lua.stx" +{ lua_codeadjust(0); yyval.vInt = lua_linenumber; } break; case 69: -# line 614 "lua.stx" -{ yyval.vInt = 1; } break; +# line 672 "lua.stx" +{ lua_codeadjust(0); yyval.vInt = lua_linenumber; } break; case 70: -# line 617 "lua.stx" -{ yyval.vInt = 0; } break; +# line 676 "lua.stx" +{ + add_localvar(luaI_findsymbol(yypvt[-0].pNode)); + } break; case 71: -# line 618 "lua.stx" -{ yyval.vInt = yypvt[-0].vInt; } break; +# line 680 "lua.stx" +{ + add_localvar(luaI_findsymbol(yypvt[-0].pNode)); + } break; case 72: -# line 621 "lua.stx" -{ if (yypvt[-0].vInt == 0) yyval.vInt = -1; else yyval.vInt = 1; } break; +# line 686 "lua.stx" +{ flush_list(yypvt[-0].vInt/FIELDS_PER_FLUSH, yypvt[-0].vInt%FIELDS_PER_FLUSH); } break; case 73: -# line 622 "lua.stx" -{ if (yypvt[-1].vInt < 0) code_byte(1); } break; +# line 688 "lua.stx" +{ yyval.vInt = yypvt[-2].vInt+yypvt[-0].vInt; } break; case 74: -# line 623 "lua.stx" -{ - int r = yypvt[-3].vInt < 0 ? -yypvt[-3].vInt : yypvt[-3].vInt; - yyval.vInt = (yypvt[-0].vInt == 0) ? -(r+1) : r+1; - } break; +# line 690 "lua.stx" +{ yyval.vInt = yypvt[-1].vInt; flush_record(yypvt[-1].vInt%FIELDS_PER_FLUSH); } break; case 75: -# line 629 "lua.stx" -{ lua_codeadjust(0); } break; +# line 694 "lua.stx" +{ yyval.vInt = 0; } break; case 76: -# line 630 "lua.stx" -{ lua_codeadjust(0); } break; -case 77: -# line 634 "lua.stx" -{ - localvar[nlocalvar]=luaI_findsymbol(yypvt[-0].pNode); - add_nlocalvar(1); - } break; -case 78: -# line 639 "lua.stx" -{ - localvar[nlocalvar]=luaI_findsymbol(yypvt[-0].pNode); - add_nlocalvar(1); - } break; +# line 696 "lua.stx" +{ yyval.vInt = yypvt[-0].vInt; flush_record(yypvt[-0].vInt%FIELDS_PER_FLUSH); } break; case 79: -# line 645 "lua.stx" -{ yyval.vInt = 0; } break; +# line 703 "lua.stx" +{ yyval.vInt = 0; } break; case 80: -# line 647 "lua.stx" -{ yyval.vInt = yypvt[-1].vInt; flush_list(yypvt[-1].vInt/FIELDS_PER_FLUSH, yypvt[-1].vInt%FIELDS_PER_FLUSH); } break; +# line 704 "lua.stx" +{ yyval.vInt = yypvt[-1].vInt; } break; case 81: -# line 649 "lua.stx" -{ yyval.vInt = yypvt[-1].vInt; flush_record(yypvt[-1].vInt%FIELDS_PER_FLUSH); } break; -case 82: -# line 651 "lua.stx" -{ flush_list(yypvt[-1].vInt/FIELDS_PER_FLUSH, yypvt[-1].vInt%FIELDS_PER_FLUSH); } break; -case 83: -# line 653 "lua.stx" -{ yyval.vInt = yypvt[-4].vInt+yypvt[-1].vInt; flush_record(yypvt[-1].vInt%FIELDS_PER_FLUSH); } break; -case 86: -# line 660 "lua.stx" +# line 707 "lua.stx" {yyval.vInt=1;} break; -case 87: -# line 662 "lua.stx" +case 82: +# line 709 "lua.stx" { yyval.vInt=yypvt[-2].vInt+1; if (yyval.vInt%FIELDS_PER_FLUSH == 0) flush_record(FIELDS_PER_FLUSH); } break; -case 88: -# line 669 "lua.stx" +case 83: +# line 716 "lua.stx" { push_field(luaI_findconstant(yypvt[-2].pNode)); } break; -case 89: -# line 674 "lua.stx" +case 84: +# line 721 "lua.stx" +{ yyval.vInt = 0; } break; +case 85: +# line 722 "lua.stx" +{ yyval.vInt = yypvt[-1].vInt; } break; +case 86: +# line 725 "lua.stx" {yyval.vInt=1;} break; -case 90: -# line 676 "lua.stx" +case 87: +# line 727 "lua.stx" { yyval.vInt=yypvt[-2].vInt+1; if (yyval.vInt%FIELDS_PER_FLUSH == 0) flush_list(yyval.vInt/FIELDS_PER_FLUSH - 1, FIELDS_PER_FLUSH); } break; -case 91: -# line 684 "lua.stx" +case 88: +# line 735 "lua.stx" { nvarbuffer = 0; - varbuffer[nvarbuffer] = yypvt[-0].vLong; incr_nvarbuffer(); + add_varbuffer(yypvt[-0].vLong); yyval.vInt = (yypvt[-0].vLong == 0) ? 1 : 0; } break; -case 92: -# line 690 "lua.stx" +case 89: +# line 741 "lua.stx" { - varbuffer[nvarbuffer] = yypvt[-0].vLong; incr_nvarbuffer(); + add_varbuffer(yypvt[-0].vLong); yyval.vInt = (yypvt[-0].vLong == 0) ? yypvt[-2].vInt + 1 : yypvt[-2].vInt; } break; -case 93: -# line 696 "lua.stx" +case 90: +# line 747 "lua.stx" { yyval.vLong = yypvt[-0].vLong; } break; -case 94: -# line 698 "lua.stx" +case 91: +# line 749 "lua.stx" { yyval.vLong = 0; /* indexed variable */ } break; -case 95: -# line 702 "lua.stx" +case 92: +# line 753 "lua.stx" { code_byte(PUSHSTRING); code_word(luaI_findconstant(yypvt[-0].pNode)); yyval.vLong = 0; /* indexed variable */ } break; -case 96: -# line 710 "lua.stx" +case 93: +# line 761 "lua.stx" { Word s = luaI_findsymbol(yypvt[-0].pNode); int local = lua_localname (s); @@ -1875,27 +1885,27 @@ case 96: else yyval.vLong = -(local+1); /* return negative value */ } break; -case 97: -# line 720 "lua.stx" +case 94: +# line 771 "lua.stx" { lua_pushvar(yypvt[-0].vLong); } break; -case 98: -# line 723 "lua.stx" -{localvar[nlocalvar]=luaI_findsymbol(yypvt[-0].pNode); yyval.vInt = 1;} break; -case 99: -# line 725 "lua.stx" +case 95: +# line 774 "lua.stx" +{store_localvar(luaI_findsymbol(yypvt[-0].pNode), 0); yyval.vInt = 1;} break; +case 96: +# line 776 "lua.stx" { - localvar[nlocalvar+yypvt[-2].vInt]=luaI_findsymbol(yypvt[-0].pNode); + store_localvar(luaI_findsymbol(yypvt[-0].pNode), yypvt[-2].vInt); yyval.vInt = yypvt[-2].vInt+1; } break; -case 100: -# line 731 "lua.stx" +case 97: +# line 782 "lua.stx" { yyval.vInt = 0; } break; -case 101: -# line 732 "lua.stx" -{ yyval.vInt = yypvt[-0].vInt; } break; -case 102: -# line 735 "lua.stx" -{lua_debug = yypvt[-0].vInt;} break; +case 98: +# line 783 "lua.stx" +{ yyval.vInt = yypvt[-0].vLong; } break; +case 99: +# line 786 "lua.stx" +{ lua_debug = yypvt[-0].vInt; } break; } goto yystack; /* reset registers in driver code */ } |
