diff options
Diffstat (limited to 'src/parser.c')
| -rw-r--r-- | src/parser.c | 1102 |
1 files changed, 439 insertions, 663 deletions
diff --git a/src/parser.c b/src/parser.c index 6b0dba94..1cbb3c17 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,25 +1,26 @@ #if defined (__cplusplus) || defined (c_plusplus) #include <c_varieties.h> #ifdef __EXTERN_C__ - EXTERN_FUNCTION ( extern int yylex, ()); + EXTERN_FUNCTION ( extern int luaY_lex, ()); #else - extern int yylex(); + extern int luaY_lex(); #endif - extern void yyerror(char *); - extern int yyparse(); + extern void luaY_error(char *); + extern int luaY_parse(); #endif -#include <malloc.h> +#include <stdlib.h> # line 2 "lua.stx" -char *rcs_luastx = "$Id: lua.stx,v 3.25 1995/10/26 17:02:50 roberto Exp $"; +char *rcs_luastx = "$Id: parser.c,v 1.1 1996/05/14 19:44:57 lhf Exp $"; #include <stdio.h> #include <stdlib.h> -#include <string.h> +#include "luadebug.h" #include "mem.h" +#include "lex.h" #include "opcode.h" #include "hash.h" #include "inout.h" @@ -29,7 +30,7 @@ char *rcs_luastx = "$Id: lua.stx,v 3.25 1995/10/26 17:02:50 roberto Exp $"; #include "func.h" /* to avoid warnings generated by yacc */ -int yyparse (void); +int luaY_parse (void); #define malloc luaI_malloc #define realloc luaI_realloc #define free luaI_free @@ -43,7 +44,7 @@ int yyparse (void); #endif static int maxcode; static int maxmain; -static Long maxcurr; /* to allow maxcurr *= 2 without overflow */ +static int maxcurr; static Byte *funcCode = NULL; static Byte **initcode; static Byte *basepc; @@ -57,35 +58,32 @@ static Long varbuffer[MAXVAR]; /* variables in an assignment list; static int nvarbuffer=0; /* number of variables at a list */ #define MAXLOCALS 32 -static Word localvar[MAXLOCALS]; /* store local variable names */ +static TaggedString *localvar[MAXLOCALS]; /* store local variable names */ static int nlocalvar=0; /* number of local variables */ #define MAXFIELDS FIELDS_PER_FLUSH*2 static Word fields[MAXFIELDS]; /* fieldnames to be flushed */ static int nfields=0; +int lua_debug = 0; /* Internal functions */ -static void yyerror (char *s) +static void luaY_error (char *s) { - static char msg[256]; - sprintf (msg,"%s near \"%s\" at line %d in file `%s'", - s, lua_lasttext (), lua_linenumber, lua_parsedfile); + char msg[256]; + char *token = lua_lasttext(); + if (token[0] == 0) + token = "<eof>"; + sprintf (msg,"%s; last token read: \"%s\" at line %d in file `%s'", + s, token, 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 */ - { - if (maxcurr >= MAX_INT) - lua_error("code size overflow"); - maxcurr *= 2; - if (maxcurr >= MAX_INT) - maxcurr = MAX_INT; - basepc = growvector(basepc, maxcurr, Byte); - } + maxcurr = growvector(&basepc, maxcurr, Byte, codeEM, MAX_INT); basepc[pc++] = c; } @@ -117,10 +115,12 @@ static void code_code (TFunc *tf) code_byte(code.m.c4); } -static void code_word_at (Byte *p, Word n) +static void code_word_at (Byte *p, int n) { CodeWord code; - code.w = n; + if ((Word)n != n) + luaY_error("block too big"); + code.w = (Word)n; *p++ = code.m.c1; *p++ = code.m.c2; } @@ -130,7 +130,7 @@ static void push_field (Word name) if (nfields < MAXFIELDS) fields[nfields++] = name; else - lua_error ("too many fields in nested constructors"); + luaY_error ("too many fields in nested constructors"); } static void flush_record (int n) @@ -155,24 +155,24 @@ static void flush_list (int m, int n) code_byte(m); } else - lua_error ("list constructor too long"); + luaY_error ("list constructor too long"); code_byte(n); } -static void add_localvar (Word name) +static void store_localvar (TaggedString *name, int n) { - if (nlocalvar < MAXLOCALS) - localvar[nlocalvar++] = name; + if (nlocalvar+n < MAXLOCALS) + localvar[nlocalvar+n] = name; else - lua_error ("too many local variables"); + luaY_error ("too many local variables"); + if (lua_debug) + luaI_registerlocalvar(name, lua_linenumber); } -static void store_localvar (Word name, int n) +static void add_localvar (TaggedString *name) { - if (nlocalvar+n < MAXLOCALS) - localvar[nlocalvar+n] = name; - else - lua_error ("too many local variables"); + store_localvar(name, 0); + nlocalvar++; } static void add_varbuffer (Long var) @@ -180,7 +180,7 @@ static void add_varbuffer (Long var) if (nvarbuffer < MAXVAR) varbuffer[nvarbuffer++] = var; else - lua_error ("variable buffer overflow"); + luaY_error ("variable buffer overflow"); } static void code_number (float f) @@ -210,7 +210,7 @@ static void code_number (float f) /* ** Search a local name and if find return its index. If do not find return -1 */ -static int lua_localname (Word n) +static int lua_localname (TaggedString *n) { int i; for (i=nlocalvar-1; i >= 0; i--) @@ -401,13 +401,12 @@ static void codeIf (Long thenAdd, Long elseAdd) */ void lua_parse (TFunc *tf) { - lua_debug = 0; initcode = &(tf->code); *initcode = newvector(CODE_BLOCK, Byte); maincode = 0; maxmain = CODE_BLOCK; change2main(); - if (yyparse ()) lua_error("parse error"); + if (luaY_parse ()) lua_error("parse error"); savemain(); (*initcode)[maincode++] = RETCODE0; tf->size = maincode; @@ -419,7 +418,7 @@ void lua_parse (TFunc *tf) -# line 411 "lua.stx" +# line 410 "lua.stx" typedef union { int vInt; @@ -428,7 +427,7 @@ typedef union Word vWord; Long vLong; TFunc *pFunc; - TreeNode *pNode; + TaggedString *pTStr; } YYSTYPE; # define WRONGTOKEN 257 # define NIL 258 @@ -457,244 +456,19 @@ typedef union # define CONC 281 # define UNARY 282 # define NOT 283 -#define yyclearin yychar = -1 -#define yyerrok yyerrflag = 0 -extern int yychar; -extern int yyerrflag; +#define luaY_clearin luaY_char = -1 +#define luaY_errok luaY_errflag = 0 +extern int luaY_char; +extern int luaY_errflag; #ifndef YYMAXDEPTH #define YYMAXDEPTH 150 #endif -YYSTYPE yylval, yyval; +YYSTYPE luaY_lval, luaY_val; # define YYERRCODE 256 -# line 789 "lua.stx" - - -#if LISTING - -static void PrintCode (Byte *code, Byte *end) -{ - Byte *p = code; - printf ("\n\nCODE\n"); - while (p != end) - { - switch ((OpCode)*p) - { - case PUSHNIL: printf ("%d PUSHNIL\n", (p++)-code); break; - case PUSH0: case PUSH1: case PUSH2: - printf ("%d PUSH%c\n", p-code, *p-PUSH0+'0'); - p++; - break; - case PUSHBYTE: - printf ("%d PUSHBYTE %d\n", p-code, *(++p)); - p++; - break; - case PUSHWORD: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d PUSHWORD %d\n", n, c.w); - } - break; - case PUSHFLOAT: - { - CodeFloat c; - int n = p-code; - p++; - get_float(c,p); - printf ("%d PUSHFLOAT %f\n", n, c.f); - } - break; - case PUSHSTRING: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d PUSHSTRING %d\n", n, c.w); - } - break; - case PUSHFUNCTION: - { - CodeCode c; - int n = p-code; - p++; - get_code(c,p); - printf ("%d PUSHFUNCTION %p\n", n, c.tf); - } - break; - - case PUSHLOCAL0: case PUSHLOCAL1: case PUSHLOCAL2: case PUSHLOCAL3: - case PUSHLOCAL4: case PUSHLOCAL5: case PUSHLOCAL6: case PUSHLOCAL7: - case PUSHLOCAL8: case PUSHLOCAL9: - printf ("%d PUSHLOCAL%c\n", p-code, *p-PUSHLOCAL0+'0'); - p++; - break; - case PUSHLOCAL: printf ("%d PUSHLOCAL %d\n", p-code, *(++p)); - p++; - break; - case PUSHGLOBAL: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d PUSHGLOBAL %d\n", n, c.w); - } - break; - case PUSHINDEXED: printf ("%d PUSHINDEXED\n", (p++)-code); break; - case STORELOCAL0: case STORELOCAL1: case STORELOCAL2: case STORELOCAL3: - case STORELOCAL4: case STORELOCAL5: case STORELOCAL6: case STORELOCAL7: - case STORELOCAL8: case STORELOCAL9: - printf ("%d STORELOCAL%c\n", p-code, *p-STORELOCAL0+'0'); - p++; - break; - case STORELOCAL: - printf ("%d STORELOCAL %d\n", p-code, *(++p)); - p++; - break; - case STOREGLOBAL: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d STOREGLOBAL %d\n", n, c.w); - } - break; - case PUSHSELF: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d PUSHSELF %d\n", n, c.w); - } - break; - case STOREINDEXED0: printf ("%d STOREINDEXED0\n", (p++)-code); break; - case STOREINDEXED: printf ("%d STOREINDEXED %d\n", p-code, *(++p)); - p++; - break; - case STORELIST0: - printf("%d STORELIST0 %d\n", p-code, *(++p)); - p++; - break; - case STORELIST: - printf("%d STORELIST %d %d\n", p-code, *(p+1), *(p+2)); - p+=3; - break; - case STORERECORD: - printf("%d STORERECORD %d\n", p-code, *(++p)); - p += *p*sizeof(Word) + 1; - break; - case ADJUST0: printf ("%d ADJUST0\n", (p++)-code); break; - case ADJUST: - printf ("%d ADJUST %d\n", p-code, *(++p)); - p++; - break; - case CREATEARRAY: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d CREATEARRAY %d\n", n, c.w); - break; - } - case EQOP: printf ("%d EQOP\n", (p++)-code); break; - case LTOP: printf ("%d LTOP\n", (p++)-code); break; - case LEOP: printf ("%d LEOP\n", (p++)-code); break; - case ADDOP: printf ("%d ADDOP\n", (p++)-code); break; - case SUBOP: printf ("%d SUBOP\n", (p++)-code); break; - case MULTOP: printf ("%d MULTOP\n", (p++)-code); break; - case DIVOP: printf ("%d DIVOP\n", (p++)-code); break; - case POWOP: printf ("%d POWOP\n", (p++)-code); break; - case CONCOP: printf ("%d CONCOP\n", (p++)-code); break; - case MINUSOP: printf ("%d MINUSOP\n", (p++)-code); break; - case NOTOP: printf ("%d NOTOP\n", (p++)-code); break; - case ONTJMP: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d ONTJMP %d\n", n, c.w); - } - break; - case ONFJMP: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d ONFJMP %d\n", n, c.w); - } - break; - case JMP: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d JMP %d\n", n, c.w); - } - break; - case UPJMP: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d UPJMP %d\n", n, c.w); - } - break; - case IFFJMP: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d IFFJMP %d\n", n, c.w); - } - break; - case IFFUPJMP: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d IFFUPJMP %d\n", n, c.w); - } - break; - case POP: printf ("%d POP\n", (p++)-code); break; - case CALLFUNC: - printf ("%d CALLFUNC %d %d\n", p-code, *(p+1), *(p+2)); - p+=3; - break; - case RETCODE0: printf ("%d RETCODE0\n", (p++)-code); break; - case RETCODE: - printf ("%d RETCODE %d\n", p-code, *(++p)); - p++; - break; - case SETLINE: - { - CodeWord c; - int n = p-code; - p++; - get_word(c,p); - printf ("%d SETLINE %d\n", n, c.w); - } - break; - - default: printf ("%d Cannot happen: code %d\n", (p++)-code, *(p-1)); break; - } - } -} -#endif +# line 788 "lua.stx" -int yyexca[] ={ +int luaY_exca[] ={ -1, 1, 0, -1, -2, 0, @@ -760,7 +534,7 @@ int yyexca[] ={ }; # define YYNPROD 100 # define YYLAST 311 -int yyact[]={ +int luaY_act[]={ 61, 59, 148, 60, 141, 62, 118, 61, 59, 90, 60, 89, 62, 86, 84, 18, 42, 168, 54, 164, @@ -794,7 +568,7 @@ int yyact[]={ 0, 0, 0, 0, 0, 30, 31, 18, 30, 31, 113, 0, 0, 0, 64, 0, 0, 34, 0, 0, 34 }; -int yypact[]={ +int luaY_pact[]={ -1000, -188, -1000, -1000, 51, -1000, -258, 24, -1000, -1000, 47, -1000, -257, -1000, -1000, 93, -1000, 73, -1000, -1000, @@ -814,14 +588,14 @@ int yypact[]={ -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[]={ +int luaY_pgo[]={ 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[]={ +int luaY_r1[]={ 0, 1, 1, 1, 23, 23, 24, 21, 21, 22, 30, 30, 26, 26, 25, 33, 25, 34, 25, 25, @@ -833,7 +607,7 @@ int yyr1[]={ 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[]={ +int luaY_r2[]={ 0, 0, 4, 4, 4, 2, 7, 3, 7, 11, 0, 6, 0, 2, 17, 1, 17, 1, 13, 7, @@ -845,7 +619,7 @@ int yyr2[]={ 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[]={ +int luaY_chk[]={ -1000, -1, -23, -24, -25, -27, 270, 259, 263, 265, -7, -5, 269, 274, -19, -9, -20, -28, 273, -26, @@ -865,7 +639,7 @@ int yychk[]={ -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[]={ +int luaY_def[]={ 1, -2, 2, 3, 12, 5, 0, 56, 15, 17, 0, 20, 0, 99, -2, 56, 90, 59, 93, 4, @@ -885,14 +659,14 @@ int yydef[]={ 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; +typedef struct { char *t_name; int t_val; } luaY_toktype; #ifndef YYDEBUG # define YYDEBUG 0 /* don't allow debugging */ #endif #if YYDEBUG -yytoktype yytoks[] = +luaY_toktype luaY_toks[] = { "WRONGTOKEN", 257, "NIL", 258, @@ -931,7 +705,7 @@ yytoktype yytoks[] = "-unknown-", -1 /* ends search */ }; -char * yyreds[] = +char * luaY_reds[] = { "-no such reduction-", "functionlist : /* empty */", @@ -1048,24 +822,24 @@ char * yyreds[] = /* ** yacc user known macros and defines */ -#define YYERROR goto yyerrlab +#define YYERROR goto luaY_errlab #define YYACCEPT return(0) #define YYABORT return(1) #define YYBACKUP( newtoken, newvalue )\ {\ - if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ + if ( luaY_char >= 0 || ( luaY_r2[ luaY_tmp ] >> 1 ) != 1 )\ {\ - yyerror( "syntax error - cannot backup" );\ - goto yyerrlab;\ + luaY_error( "syntax error - cannot backup" );\ + goto luaY_errlab;\ }\ - yychar = newtoken;\ - yystate = *yyps;\ - yylval = newvalue;\ - goto yynewstate;\ + luaY_char = newtoken;\ + luaY_state = *luaY_ps;\ + luaY_lval = newvalue;\ + goto luaY_newstate;\ } -#define YYRECOVERING() (!!yyerrflag) +#define YYRECOVERING() (!!luaY_errflag) #define YYCOPY(to, from, type) \ - (type *) memcpy(to, (char *) from, yynewmax * sizeof(type)) + (type *) memcpy(to, (char *) from, luaY_newmax * sizeof(type)) #ifndef YYDEBUG # define YYDEBUG 1 /* make debugging available */ #endif @@ -1085,7 +859,7 @@ EXTERN_FUNCTION ( extern void *memcpy, (void *, const void *, int) ); /* ** user known globals */ -int yydebug; /* set to 1 to get debugging */ +int luaY_debug; /* set to 1 to get debugging */ /* ** driver internal defines @@ -1095,50 +869,50 @@ int yydebug; /* set to 1 to get debugging */ /* ** static variables used by the parser */ -static YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv; /* value stack */ -static int yy_yys[YYMAXDEPTH], *yys = yy_yys; /* state stack */ +static YYSTYPE luaY__luaY_v[YYMAXDEPTH], *luaY_v = luaY__luaY_v; /* value stack */ +static int luaY__luaY_s[YYMAXDEPTH], *luaY_s = luaY__luaY_s; /* state stack */ -static YYSTYPE *yypv; /* top of value stack */ -static int *yyps; /* top of state stack */ +static YYSTYPE *luaY_pv; /* top of value stack */ +static int *luaY_ps; /* top of state stack */ -static int yystate; /* current state */ -static int yytmp; /* extra var (lasts between blocks) */ +static int luaY_state; /* current state */ +static int luaY_tmp; /* extra var (lasts between blocks) */ #if defined(__cplusplus) || defined(__STDC__) || defined(lint) static int __yaccpar_lint_hack__ = 0; /* if you change the value from 0 to something else, make sure you know - what to do with yyerrlab reference. + what to do with luaY_errlab reference. This is a hack - to make sure C++ and lint are happy with the 4.1 yacc code. */ #endif -int yynerrs; /* number of errors */ +int luaY_nerrs; /* number of errors */ -int yyerrflag; /* error recovery flag */ -int yychar; /* current input token number */ -static unsigned yymaxdepth = YYMAXDEPTH; +int luaY_errflag; /* error recovery flag */ +int luaY_char; /* current input token number */ +static unsigned luaY_maxdepth = YYMAXDEPTH; /* -** yyparse - return 0 if worked, 1 if syntax error not recovered from +** luaY_parse - return 0 if worked, 1 if syntax error not recovered from */ int -yyparse() +luaY_parse() { - register YYSTYPE *yypvt = (YYSTYPE*)0 ; /* top of value stack for + register YYSTYPE *luaY_pvt = (YYSTYPE*)0 ; /* top of value stack for $vars */ /* - ** Initialize externals - yyparse may be called more than once + ** Initialize externals - luaY_parse may be called more than once */ - yypv = &yyv[-1]; - yyps = &yys[-1]; - yystate = 0; - yytmp = 0; - yynerrs = 0; - yyerrflag = 0; - yychar = -1; + luaY_pv = &luaY_v[-1]; + luaY_ps = &luaY_s[-1]; + luaY_state = 0; + luaY_tmp = 0; + luaY_nerrs = 0; + luaY_errflag = 0; + luaY_char = -1; #if defined(__cplusplus) || defined(__STDC__) || defined(lint) /* @@ -1147,42 +921,42 @@ $vars */ */ switch (__yaccpar_lint_hack__) { - case 1: goto yyerrlab; - case 2: goto yynewstate; + case 1: goto luaY_errlab; + case 2: goto luaY_newstate; } #endif { - register YYSTYPE *yy_pv; /* top of value stack */ - register int *yy_ps; /* top of state stack */ - register int yy_state; /* current state */ - register int yy_n; /* internal state number info */ + register YYSTYPE *luaY__pv; /* top of value stack */ + register int *luaY__ps; /* top of state stack */ + register int luaY__state; /* current state */ + register int luaY__n; /* internal state number info */ - goto yystack; + goto luaY_stack; /* ** get globals into registers. ** branch to here only if YYBACKUP was called. */ - yynewstate: - yy_pv = yypv; - yy_ps = yyps; - yy_state = yystate; - goto yy_newstate; + luaY_newstate: + luaY__pv = luaY_pv; + luaY__ps = luaY_ps; + luaY__state = luaY_state; + goto luaY__newstate; /* ** get globals into registers. ** either we just started, or we just finished a reduction */ - yystack: - yy_pv = yypv; - yy_ps = yyps; - yy_state = yystate; + luaY_stack: + luaY__pv = luaY_pv; + luaY__ps = luaY_ps; + luaY__state = luaY_state; /* ** top of for (;;) loop while no reductions done */ - yy_stack: + luaY__stack: /* ** put a state and value onto the stacks */ @@ -1193,153 +967,153 @@ $vars */ ** Note: linear search is used since time is not a real ** consideration while debugging. */ - if ( yydebug ) + if ( luaY_debug ) { - register int yy_i; + register int luaY__i; - (void)printf( "State %d, token ", yy_state ); - if ( yychar == 0 ) + (void)printf( "State %d, token ", luaY__state ); + if ( luaY_char == 0 ) (void)printf( "end-of-file\n" ); - else if ( yychar < 0 ) + else if ( luaY_char < 0 ) (void)printf( "-none-\n" ); else { - for ( yy_i = 0; yytoks[yy_i].t_val >= 0; - yy_i++ ) + for ( luaY__i = 0; luaY_toks[luaY__i].t_val >= 0; + luaY__i++ ) { - if ( yytoks[yy_i].t_val == yychar ) + if ( luaY_toks[luaY__i].t_val == luaY_char ) break; } - (void)printf( "%s\n", yytoks[yy_i].t_name ); + (void)printf( "%s\n", luaY_toks[luaY__i].t_name ); } } #endif /* YYDEBUG */ - if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ + if ( ++luaY__ps >= &luaY_s[ luaY_maxdepth ] ) /* room on stack? */ { /* ** reallocate and recover. Note that pointers ** have to be reset, or bad things will happen */ - int yyps_index = (yy_ps - yys); - int yypv_index = (yy_pv - yyv); - int yypvt_index = (yypvt - yyv); - int yynewmax; + int luaY_ps_index = (luaY__ps - luaY_s); + int luaY_pv_index = (luaY__pv - luaY_v); + int luaY_pvt_index = (luaY_pvt - luaY_v); + int luaY_newmax; - yynewmax = yymaxdepth + YYMAXDEPTH; - if (yymaxdepth == YYMAXDEPTH) /* first time growth */ + luaY_newmax = luaY_maxdepth + YYMAXDEPTH; + if (luaY_maxdepth == YYMAXDEPTH) /* first time growth */ { - YYSTYPE *newyyv = (YYSTYPE*)malloc(yynewmax*sizeof(YYSTYPE)); - int *newyys = (int*)malloc(yynewmax*sizeof(int)); - if (newyys != 0 && newyyv != 0) + YYSTYPE *newluaY_v = (YYSTYPE*)malloc(luaY_newmax*sizeof(YYSTYPE)); + int *newluaY_s = (int*)malloc(luaY_newmax*sizeof(int)); + if (newluaY_s != 0 && newluaY_v != 0) { - yys = YYCOPY(newyys, yys, int); - yyv = YYCOPY(newyyv, yyv, YYSTYPE); + luaY_s = YYCOPY(newluaY_s, luaY_s, int); + luaY_v = YYCOPY(newluaY_v, luaY_v, YYSTYPE); } else - yynewmax = 0; /* failed */ + luaY_newmax = 0; /* failed */ } else /* not first time */ { - yyv = (YYSTYPE*)realloc((char*)yyv, - yynewmax * sizeof(YYSTYPE)); - yys = (int*)realloc((char*)yys, - yynewmax * sizeof(int)); - if (yys == 0 || yyv == 0) - yynewmax = 0; /* failed */ + luaY_v = (YYSTYPE*)realloc((char*)luaY_v, + luaY_newmax * sizeof(YYSTYPE)); + luaY_s = (int*)realloc((char*)luaY_s, + luaY_newmax * sizeof(int)); + if (luaY_s == 0 || luaY_v == 0) + luaY_newmax = 0; /* failed */ } - if (yynewmax <= yymaxdepth) /* tables not expanded */ + if (luaY_newmax <= luaY_maxdepth) /* tables not expanded */ { - yyerror( "yacc stack overflow" ); + luaY_error( "yacc stack overflow" ); YYABORT; } - yymaxdepth = yynewmax; + luaY_maxdepth = luaY_newmax; - yy_ps = yys + yyps_index; - yy_pv = yyv + yypv_index; - yypvt = yyv + yypvt_index; + luaY__ps = luaY_s + luaY_ps_index; + luaY__pv = luaY_v + luaY_pv_index; + luaY_pvt = luaY_v + luaY_pvt_index; } - *yy_ps = yy_state; - *++yy_pv = yyval; + *luaY__ps = luaY__state; + *++luaY__pv = luaY_val; /* ** we have a new state - find out what to do */ - yy_newstate: - if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) - goto yydefault; /* simple state */ + luaY__newstate: + if ( ( luaY__n = luaY_pact[ luaY__state ] ) <= YYFLAG ) + goto luaY_default; /* simple state */ #if YYDEBUG /* ** if debugging, need to mark whether new token grabbed */ - yytmp = yychar < 0; + luaY_tmp = luaY_char < 0; #endif - if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) - yychar = 0; /* reached EOF */ + if ( ( luaY_char < 0 ) && ( ( luaY_char = luaY_lex() ) < 0 ) ) + luaY_char = 0; /* reached EOF */ #if YYDEBUG - if ( yydebug && yytmp ) + if ( luaY_debug && luaY_tmp ) { - register int yy_i; + register int luaY__i; (void)printf( "Received token " ); - if ( yychar == 0 ) + if ( luaY_char == 0 ) (void)printf( "end-of-file\n" ); - else if ( yychar < 0 ) + else if ( luaY_char < 0 ) (void)printf( "-none-\n" ); else { - for ( yy_i = 0; yytoks[yy_i].t_val >= 0; - yy_i++ ) + for ( luaY__i = 0; luaY_toks[luaY__i].t_val >= 0; + luaY__i++ ) { - if ( yytoks[yy_i].t_val == yychar ) + if ( luaY_toks[luaY__i].t_val == luaY_char ) break; } - (void)printf( "%s\n", yytoks[yy_i].t_name ); + (void)printf( "%s\n", luaY_toks[luaY__i].t_name ); } } #endif /* YYDEBUG */ - if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) - goto yydefault; - if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ + if ( ( ( luaY__n += luaY_char ) < 0 ) || ( luaY__n >= YYLAST ) ) + goto luaY_default; + if ( luaY_chk[ luaY__n = luaY_act[ luaY__n ] ] == luaY_char ) /*valid shift*/ { - yychar = -1; - yyval = yylval; - yy_state = yy_n; - if ( yyerrflag > 0 ) - yyerrflag--; - goto yy_stack; + luaY_char = -1; + luaY_val = luaY_lval; + luaY__state = luaY__n; + if ( luaY_errflag > 0 ) + luaY_errflag--; + goto luaY__stack; } - yydefault: - if ( ( yy_n = yydef[ yy_state ] ) == -2 ) + luaY_default: + if ( ( luaY__n = luaY_def[ luaY__state ] ) == -2 ) { #if YYDEBUG - yytmp = yychar < 0; + luaY_tmp = luaY_char < 0; #endif - if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) - yychar = 0; /* reached EOF */ + if ( ( luaY_char < 0 ) && ( ( luaY_char = luaY_lex() ) < 0 ) ) + luaY_char = 0; /* reached EOF */ #if YYDEBUG - if ( yydebug && yytmp ) + if ( luaY_debug && luaY_tmp ) { - register int yy_i; + register int luaY__i; (void)printf( "Received token " ); - if ( yychar == 0 ) + if ( luaY_char == 0 ) (void)printf( "end-of-file\n" ); - else if ( yychar < 0 ) + else if ( luaY_char < 0 ) (void)printf( "-none-\n" ); else { - for ( yy_i = 0; - yytoks[yy_i].t_val >= 0; - yy_i++ ) + for ( luaY__i = 0; + luaY_toks[luaY__i].t_val >= 0; + luaY__i++ ) { - if ( yytoks[yy_i].t_val - == yychar ) + if ( luaY_toks[luaY__i].t_val + == luaY_char ) { break; } } - (void)printf( "%s\n", yytoks[yy_i].t_name ); + (void)printf( "%s\n", luaY_toks[luaY__i].t_name ); } } #endif /* YYDEBUG */ @@ -1347,17 +1121,17 @@ $vars */ ** look through exception table */ { - register int *yyxi = yyexca; + register int *luaY_xi = luaY_exca; - while ( ( *yyxi != -1 ) || - ( yyxi[1] != yy_state ) ) + while ( ( *luaY_xi != -1 ) || + ( luaY_xi[1] != luaY__state ) ) { - yyxi += 2; + luaY_xi += 2; } - while ( ( *(yyxi += 2) >= 0 ) && - ( *yyxi != yychar ) ) + while ( ( *(luaY_xi += 2) >= 0 ) && + ( *luaY_xi != luaY_char ) ) ; - if ( ( yy_n = yyxi[1] ) < 0 ) + if ( ( luaY__n = luaY_xi[1] ) < 0 ) YYACCEPT; } } @@ -1365,42 +1139,42 @@ $vars */ /* ** check for syntax error */ - if ( yy_n == 0 ) /* have an error */ + if ( luaY__n == 0 ) /* have an error */ { /* no worry about speed here! */ - switch ( yyerrflag ) + switch ( luaY_errflag ) { case 0: /* new error */ - yyerror( "syntax error" ); + luaY_error( "syntax error" ); goto skip_init; - yyerrlab: + luaY_errlab: /* ** get globals into registers. ** we have a user generated syntax type error */ - yy_pv = yypv; - yy_ps = yyps; - yy_state = yystate; - yynerrs++; + luaY__pv = luaY_pv; + luaY__ps = luaY_ps; + luaY__state = luaY_state; + luaY_nerrs++; skip_init: case 1: case 2: /* incompletely recovered error */ /* try again... */ - yyerrflag = 3; + luaY_errflag = 3; /* ** find state where "error" is a legal ** shift action */ - while ( yy_ps >= yys ) + while ( luaY__ps >= luaY_s ) { - yy_n = yypact[ *yy_ps ] + YYERRCODE; - if ( yy_n >= 0 && yy_n < YYLAST && - yychk[yyact[yy_n]] == YYERRCODE) { + luaY__n = luaY_pact[ *luaY__ps ] + YYERRCODE; + if ( luaY__n >= 0 && luaY__n < YYLAST && + luaY_chk[luaY_act[luaY__n]] == YYERRCODE) { /* ** simulate shift of "error" */ - yy_state = yyact[ yy_n ]; - goto yy_stack; + luaY__state = luaY_act[ luaY__n ]; + goto luaY__stack; } /* ** current state has no shift on @@ -1408,13 +1182,13 @@ $vars */ */ #if YYDEBUG # define _POP_ "Error recovery pops state %d, uncovers state %d\n" - if ( yydebug ) - (void)printf( _POP_, *yy_ps, - yy_ps[-1] ); + if ( luaY_debug ) + (void)printf( _POP_, *luaY__ps, + luaY__ps[-1] ); # undef _POP_ #endif - yy_ps--; - yy_pv--; + luaY__ps--; + luaY__pv--; } /* ** there is no state on stack with "error" as @@ -1430,40 +1204,40 @@ $vars */ ** debugging, it doesn't hurt to leave the ** tests here. */ - if ( yydebug ) + if ( luaY_debug ) { - register int yy_i; + register int luaY__i; (void)printf( "Error recovery discards " ); - if ( yychar == 0 ) + if ( luaY_char == 0 ) (void)printf( "token end-of-file\n" ); - else if ( yychar < 0 ) + else if ( luaY_char < 0 ) (void)printf( "token -none-\n" ); else { - for ( yy_i = 0; - yytoks[yy_i].t_val >= 0; - yy_i++ ) + for ( luaY__i = 0; + luaY_toks[luaY__i].t_val >= 0; + luaY__i++ ) { - if ( yytoks[yy_i].t_val - == yychar ) + if ( luaY_toks[luaY__i].t_val + == luaY_char ) { break; } } (void)printf( "token %s\n", - yytoks[yy_i].t_name ); + luaY_toks[luaY__i].t_name ); } } #endif /* YYDEBUG */ - if ( yychar == 0 ) /* reached EOF. quit */ + if ( luaY_char == 0 ) /* reached EOF. quit */ YYABORT; - yychar = -1; - goto yy_newstate; + luaY_char = -1; + goto luaY__newstate; } - }/* end if ( yy_n == 0 ) */ + }/* end if ( luaY__n == 0 ) */ /* - ** reduction by production yy_n + ** reduction by production luaY__n ** put stack tops, etc. so things right after switch */ #if YYDEBUG @@ -1472,92 +1246,95 @@ $vars */ ** specification of the reduction which is just about ** to be done. */ - if ( yydebug ) + if ( luaY_debug ) (void)printf( "Reduce by (%d) \"%s\"\n", - yy_n, yyreds[ yy_n ] ); + luaY__n, luaY_reds[ luaY__n ] ); #endif - yytmp = yy_n; /* value to switch over */ - yypvt = yy_pv; /* $vars top of value stack */ + luaY_tmp = luaY__n; /* value to switch over */ + luaY_pvt = luaY__pv; /* $vars top of value stack */ /* ** Look in goto table for next state - ** Sorry about using yy_state here as temporary + ** Sorry about using luaY__state here as temporary ** register variable, but why not, if it works... - ** If yyr2[ yy_n ] doesn't have the low order bit + ** If luaY_r2[ luaY__n ] doesn't have the low order bit ** set, then there is no action to be done for ** this reduction. So, no saving & unsaving of ** registers done. The only difference between the ** code just after the if and the body of the if is - ** the goto yy_stack in the body. This way the test + ** the goto luaY__stack in the body. This way the test ** can be made before the choice of what to do is needed. */ { /* length of production doubled with extra bit */ - register int yy_len = yyr2[ yy_n ]; + register int luaY__len = luaY_r2[ luaY__n ]; - if ( !( yy_len & 01 ) ) + if ( !( luaY__len & 01 ) ) { - yy_len >>= 1; - yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ - yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + - *( yy_ps -= yy_len ) + 1; - if ( yy_state >= YYLAST || - yychk[ yy_state = - yyact[ yy_state ] ] != -yy_n ) + luaY__len >>= 1; + luaY_val = ( luaY__pv -= luaY__len )[1]; /* $$ = $1 */ + luaY__state = luaY_pgo[ luaY__n = luaY_r1[ luaY__n ] ] + + *( luaY__ps -= luaY__len ) + 1; + if ( luaY__state >= YYLAST || + luaY_chk[ luaY__state = + luaY_act[ luaY__state ] ] != -luaY__n ) { - yy_state = yyact[ yypgo[ yy_n ] ]; + luaY__state = luaY_act[ luaY_pgo[ luaY__n ] ]; } - goto yy_stack; + goto luaY__stack; } - yy_len >>= 1; - yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ - yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + - *( yy_ps -= yy_len ) + 1; - if ( yy_state >= YYLAST || - yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) + luaY__len >>= 1; + luaY_val = ( luaY__pv -= luaY__len )[1]; /* $$ = $1 */ + luaY__state = luaY_pgo[ luaY__n = luaY_r1[ luaY__n ] ] + + *( luaY__ps -= luaY__len ) + 1; + if ( luaY__state >= YYLAST || + luaY_chk[ luaY__state = luaY_act[ luaY__state ] ] != -luaY__n ) { - yy_state = yyact[ yypgo[ yy_n ] ]; + luaY__state = luaY_act[ luaY_pgo[ luaY__n ] ]; } } /* save until reenter driver code */ - yystate = yy_state; - yyps = yy_ps; - yypv = yy_pv; + luaY_state = luaY__state; + luaY_ps = luaY__ps; + luaY_pv = luaY__pv; } /* ** code supplied by user is placed in this switch */ - switch( yytmp ) + switch( luaY_tmp ) { case 6: -# line 470 "lua.stx" +# line 469 "lua.stx" { code_byte(PUSHFUNCTION); - code_code(yypvt[-0].pFunc); - storesinglevar(yypvt[-1].vLong); + code_code(luaY_pvt[-0].pFunc); + storesinglevar(luaY_pvt[-1].vLong); } break; case 7: -# line 477 "lua.stx" -{ yyval.vLong =yypvt[-0].vLong; init_func(); } break; +# line 476 "lua.stx" +{ luaY_val.vLong =luaY_pvt[-0].vLong; init_func(); } break; case 8: -# line 479 "lua.stx" +# line 478 "lua.stx" { code_byte(PUSHSTRING); - code_word(luaI_findconstant(yypvt[-0].pNode)); - yyval.vLong = 0; /* indexed variable */ + code_word(luaI_findconstant(luaY_pvt[-0].pTStr)); + luaY_val.vLong = 0; /* indexed variable */ init_func(); - add_localvar(luaI_findsymbolbyname("self")); + add_localvar(luaI_createfixedstring("self")); } break; case 9: -# line 489 "lua.stx" +# line 488 "lua.stx" { codereturn(); - 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)); + luaY_val.pFunc = new(TFunc); + luaI_initTFunc(luaY_val.pFunc); + luaY_val.pFunc->size = pc; + luaY_val.pFunc->code = newvector(pc, Byte); + luaY_val.pFunc->fileName = lua_parsedfile; + luaY_val.pFunc->lineDefined = luaY_pvt[-3].vInt; + memcpy(luaY_val.pFunc->code, basepc, pc*sizeof(Byte)); + if (lua_debug) + luaI_closelocalvars(luaY_val.pFunc); /* save func values */ funcCode = basepc; maxcode=maxcurr; #if LISTING @@ -1566,346 +1343,345 @@ case 9: change2main(); /* change back to main code */ } break; case 14: -# line 513 "lua.stx" -{ codeIf(yypvt[-4].vLong, yypvt[-2].vLong); } break; -case 15: # line 515 "lua.stx" -{yyval.vLong=pc;} break; +{ codeIf(luaY_pvt[-4].vLong, luaY_pvt[-2].vLong); } break; +case 15: +# line 517 "lua.stx" +{luaY_val.vLong=pc;} break; case 16: -# line 516 "lua.stx" +# line 518 "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)); + basepc[luaY_pvt[-3].vLong] = IFFJMP; + code_word_at(basepc+luaY_pvt[-3].vLong+1, pc - (luaY_pvt[-3].vLong + sizeof(Word)+1)); + basepc[luaY_pvt[-1].vLong] = UPJMP; + code_word_at(basepc+luaY_pvt[-1].vLong+1, pc - (luaY_pvt[-6].vLong)); } break; case 17: -# line 523 "lua.stx" -{yyval.vLong=pc;} break; +# line 525 "lua.stx" +{luaY_val.vLong=pc;} break; case 18: -# line 524 "lua.stx" +# line 526 "lua.stx" { - basepc[yypvt[-0].vLong] = IFFUPJMP; - code_word_at(basepc+yypvt[-0].vLong+1, pc - (yypvt[-4].vLong)); + basepc[luaY_pvt[-0].vLong] = IFFUPJMP; + code_word_at(basepc+luaY_pvt[-0].vLong+1, pc - (luaY_pvt[-4].vLong)); } break; case 19: -# line 530 "lua.stx" +# line 532 "lua.stx" { { int i; - adjust_mult_assign(nvarbuffer, yypvt[-0].vLong, yypvt[-2].vInt * 2 + nvarbuffer); + adjust_mult_assign(nvarbuffer, luaY_pvt[-0].vLong, luaY_pvt[-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)) + if (luaY_pvt[-2].vInt > 1 || (luaY_pvt[-2].vInt == 1 && varbuffer[0] != 0)) lua_codeadjust (0); } } break; case 21: -# line 542 "lua.stx" -{ nlocalvar += yypvt[-1].vInt; - adjust_mult_assign(yypvt[-1].vInt, yypvt[-0].vInt, 0); +# line 544 "lua.stx" +{ nlocalvar += luaY_pvt[-1].vInt; + adjust_mult_assign(luaY_pvt[-1].vInt, luaY_pvt[-0].vInt, 0); } break; case 24: -# line 550 "lua.stx" -{ codeIf(yypvt[-3].vLong, yypvt[-1].vLong); } break; +# line 552 "lua.stx" +{ codeIf(luaY_pvt[-3].vLong, luaY_pvt[-1].vLong); } break; case 25: -# line 553 "lua.stx" -{yyval.vInt = nlocalvar;} break; +# line 555 "lua.stx" +{luaY_val.vInt = nlocalvar;} break; case 26: -# line 554 "lua.stx" +# line 556 "lua.stx" { - if (nlocalvar != yypvt[-2].vInt) + if (nlocalvar != luaY_pvt[-2].vInt) { - nlocalvar = yypvt[-2].vInt; + if (lua_debug) + for (; nlocalvar > luaY_pvt[-2].vInt; nlocalvar--) + luaI_unregisterlocalvar(lua_linenumber); + else + nlocalvar = luaY_pvt[-2].vInt; lua_codeadjust (0); } } break; case 28: -# line 565 "lua.stx" +# line 571 "lua.stx" { - adjust_functioncall(yypvt[-1].vLong, MULT_RET); + adjust_functioncall(luaY_pvt[-1].vLong, MULT_RET); codereturn(); } break; case 29: -# line 572 "lua.stx" +# line 578 "lua.stx" { - yyval.vLong = pc; + luaY_val.vLong = pc; code_byte(0); /* open space */ code_word (0); } break; case 30: -# line 578 "lua.stx" -{ adjust_functioncall(yypvt[-0].vLong, 1); } break; +# line 584 "lua.stx" +{ adjust_functioncall(luaY_pvt[-0].vLong, 1); } break; case 31: -# line 581 "lua.stx" -{ yyval.vLong = yypvt[-1].vLong; } break; +# line 587 "lua.stx" +{ luaY_val.vLong = luaY_pvt[-1].vLong; } break; case 32: -# line 582 "lua.stx" -{ code_byte(EQOP); yyval.vLong = 0; } break; +# line 588 "lua.stx" +{ code_byte(EQOP); luaY_val.vLong = 0; } break; case 33: -# line 583 "lua.stx" -{ code_byte(LTOP); yyval.vLong = 0; } break; +# line 589 "lua.stx" +{ code_byte(LTOP); luaY_val.vLong = 0; } break; case 34: -# line 584 "lua.stx" -{ code_byte(GTOP); yyval.vLong = 0; } break; +# line 590 "lua.stx" +{ code_byte(GTOP); luaY_val.vLong = 0; } break; case 35: -# line 585 "lua.stx" -{ code_byte(EQOP); code_byte(NOTOP); yyval.vLong = 0; } break; +# line 591 "lua.stx" +{ code_byte(EQOP); code_byte(NOTOP); luaY_val.vLong = 0; } break; case 36: -# line 586 "lua.stx" -{ code_byte(LEOP); yyval.vLong = 0; } break; +# line 592 "lua.stx" +{ code_byte(LEOP); luaY_val.vLong = 0; } break; case 37: -# line 587 "lua.stx" -{ code_byte(GEOP); yyval.vLong = 0; } break; +# line 593 "lua.stx" +{ code_byte(GEOP); luaY_val.vLong = 0; } break; case 38: -# line 588 "lua.stx" -{ code_byte(ADDOP); yyval.vLong = 0; } break; +# line 594 "lua.stx" +{ code_byte(ADDOP); luaY_val.vLong = 0; } break; case 39: -# line 589 "lua.stx" -{ code_byte(SUBOP); yyval.vLong = 0; } break; +# line 595 "lua.stx" +{ code_byte(SUBOP); luaY_val.vLong = 0; } break; case 40: -# line 590 "lua.stx" -{ code_byte(MULTOP); yyval.vLong = 0; } break; +# line 596 "lua.stx" +{ code_byte(MULTOP); luaY_val.vLong = 0; } break; case 41: -# line 591 "lua.stx" -{ code_byte(DIVOP); yyval.vLong = 0; } break; +# line 597 "lua.stx" +{ code_byte(DIVOP); luaY_val.vLong = 0; } break; case 42: -# line 592 "lua.stx" -{ code_byte(POWOP); yyval.vLong = 0; } break; +# line 598 "lua.stx" +{ code_byte(POWOP); luaY_val.vLong = 0; } break; case 43: -# line 593 "lua.stx" -{ code_byte(CONCOP); yyval.vLong = 0; } break; +# line 599 "lua.stx" +{ code_byte(CONCOP); luaY_val.vLong = 0; } break; case 44: -# line 594 "lua.stx" -{ code_byte(MINUSOP); yyval.vLong = 0;} break; +# line 600 "lua.stx" +{ code_byte(MINUSOP); luaY_val.vLong = 0;} break; case 45: -# line 595 "lua.stx" -{ yyval.vLong = 0; } break; +# line 601 "lua.stx" +{ luaY_val.vLong = 0; } break; case 46: -# line 596 "lua.stx" -{ yyval.vLong = 0;} break; +# line 602 "lua.stx" +{ luaY_val.vLong = 0;} break; case 47: -# line 597 "lua.stx" -{ code_number(yypvt[-0].vFloat); yyval.vLong = 0; } break; +# line 603 "lua.stx" +{ code_number(luaY_pvt[-0].vFloat); luaY_val.vLong = 0; } break; case 48: -# line 599 "lua.stx" +# line 605 "lua.stx" { code_byte(PUSHSTRING); - code_word(yypvt[-0].vWord); - yyval.vLong = 0; + code_word(luaY_pvt[-0].vWord); + luaY_val.vLong = 0; } break; case 49: -# line 604 "lua.stx" -{code_byte(PUSHNIL); yyval.vLong = 0; } break; +# line 610 "lua.stx" +{code_byte(PUSHNIL); luaY_val.vLong = 0; } break; case 50: -# line 605 "lua.stx" -{ yyval.vLong = yypvt[-0].vLong; } break; +# line 611 "lua.stx" +{ luaY_val.vLong = luaY_pvt[-0].vLong; } break; case 51: -# line 606 "lua.stx" -{ code_byte(NOTOP); yyval.vLong = 0;} break; +# line 612 "lua.stx" +{ code_byte(NOTOP); luaY_val.vLong = 0;} break; case 52: -# line 607 "lua.stx" +# line 613 "lua.stx" {code_byte(POP); } break; case 53: -# line 608 "lua.stx" +# line 614 "lua.stx" { - basepc[yypvt[-2].vLong] = ONFJMP; - code_word_at(basepc+yypvt[-2].vLong+1, pc - (yypvt[-2].vLong + sizeof(Word)+1)); - yyval.vLong = 0; + basepc[luaY_pvt[-2].vLong] = ONFJMP; + code_word_at(basepc+luaY_pvt[-2].vLong+1, pc - (luaY_pvt[-2].vLong + sizeof(Word)+1)); + luaY_val.vLong = 0; } break; case 54: -# line 613 "lua.stx" +# line 619 "lua.stx" {code_byte(POP); } break; case 55: -# line 614 "lua.stx" +# line 620 "lua.stx" { - basepc[yypvt[-2].vLong] = ONTJMP; - code_word_at(basepc+yypvt[-2].vLong+1, pc - (yypvt[-2].vLong + sizeof(Word)+1)); - yyval.vLong = 0; + basepc[luaY_pvt[-2].vLong] = ONTJMP; + code_word_at(basepc+luaY_pvt[-2].vLong+1, pc - (luaY_pvt[-2].vLong + sizeof(Word)+1)); + luaY_val.vLong = 0; } break; case 56: -# line 622 "lua.stx" +# line 628 "lua.stx" { code_byte(CREATEARRAY); - yyval.vLong = pc; code_word(0); + luaY_val.vLong = pc; code_word(0); } break; case 57: -# line 627 "lua.stx" +# line 633 "lua.stx" { - code_word_at(basepc+yypvt[-3].vLong, yypvt[-1].vInt); + code_word_at(basepc+luaY_pvt[-3].vLong, luaY_pvt[-1].vInt); } break; case 58: -# line 633 "lua.stx" +# line 639 "lua.stx" { code_byte(CALLFUNC); - code_byte(yypvt[-1].vInt+yypvt[-0].vInt); - yyval.vLong = pc; + code_byte(luaY_pvt[-1].vInt+luaY_pvt[-0].vInt); + luaY_val.vLong = pc; code_byte(0); /* may be modified by other rules */ } break; case 59: -# line 641 "lua.stx" -{ yyval.vInt = 0; } break; +# line 647 "lua.stx" +{ luaY_val.vInt = 0; } break; case 60: -# line 643 "lua.stx" +# line 649 "lua.stx" { code_byte(PUSHSELF); - code_word(luaI_findconstant(yypvt[-0].pNode)); - yyval.vInt = 1; + code_word(luaI_findconstant(luaY_pvt[-0].pTStr)); + luaY_val.vInt = 1; } break; case 61: -# line 651 "lua.stx" -{ yyval.vInt = adjust_functioncall(yypvt[-1].vLong, 1); } break; +# line 657 "lua.stx" +{ luaY_val.vInt = adjust_functioncall(luaY_pvt[-1].vLong, 1); } break; case 62: -# line 652 "lua.stx" -{ yyval.vInt = 1; } break; +# line 658 "lua.stx" +{ luaY_val.vInt = 1; } break; case 63: -# line 655 "lua.stx" -{ yyval.vLong = 0; } break; +# line 661 "lua.stx" +{ luaY_val.vLong = 0; } break; case 64: -# line 656 "lua.stx" -{ yyval.vLong = yypvt[-0].vLong; } break; +# line 662 "lua.stx" +{ luaY_val.vLong = luaY_pvt[-0].vLong; } break; case 65: -# line 659 "lua.stx" -{ if (yypvt[-0].vLong != 0) yyval.vLong = yypvt[-0].vLong; else yyval.vLong = -1; } break; +# line 665 "lua.stx" +{ if (luaY_pvt[-0].vLong != 0) luaY_val.vLong = luaY_pvt[-0].vLong; else luaY_val.vLong = -1; } break; case 66: -# line 660 "lua.stx" -{ yyval.vLong = adjust_functioncall(yypvt[-1].vLong, 1); } break; +# line 666 "lua.stx" +{ luaY_val.vLong = adjust_functioncall(luaY_pvt[-1].vLong, 1); } break; case 67: -# line 661 "lua.stx" +# line 667 "lua.stx" { - if (yypvt[-0].vLong == 0) yyval.vLong = -(yypvt[-1].vLong + 1); /* -length */ + if (luaY_pvt[-0].vLong == 0) luaY_val.vLong = -(luaY_pvt[-1].vLong + 1); /* -length */ else { - adjust_functioncall(yypvt[-0].vLong, yypvt[-1].vLong); - yyval.vLong = yypvt[-0].vLong; + adjust_functioncall(luaY_pvt[-0].vLong, luaY_pvt[-1].vLong); + luaY_val.vLong = luaY_pvt[-0].vLong; } } break; case 68: -# line 671 "lua.stx" -{ lua_codeadjust(0); yyval.vInt = lua_linenumber; } break; +# line 677 "lua.stx" +{ lua_codeadjust(0); luaY_val.vInt = lua_linenumber; } break; case 69: -# line 672 "lua.stx" -{ lua_codeadjust(0); yyval.vInt = lua_linenumber; } break; +# line 678 "lua.stx" +{ lua_codeadjust(0); luaY_val.vInt = lua_linenumber; } break; case 70: -# line 676 "lua.stx" -{ - add_localvar(luaI_findsymbol(yypvt[-0].pNode)); - } break; +# line 681 "lua.stx" +{ add_localvar(luaY_pvt[-0].pTStr); } break; case 71: -# line 680 "lua.stx" -{ - add_localvar(luaI_findsymbol(yypvt[-0].pNode)); - } break; +# line 682 "lua.stx" +{ add_localvar(luaY_pvt[-0].pTStr); } break; case 72: # line 686 "lua.stx" -{ flush_list(yypvt[-0].vInt/FIELDS_PER_FLUSH, yypvt[-0].vInt%FIELDS_PER_FLUSH); } break; +{ flush_list(luaY_pvt[-0].vInt/FIELDS_PER_FLUSH, luaY_pvt[-0].vInt%FIELDS_PER_FLUSH); } break; case 73: # line 688 "lua.stx" -{ yyval.vInt = yypvt[-2].vInt+yypvt[-0].vInt; } break; +{ luaY_val.vInt = luaY_pvt[-2].vInt+luaY_pvt[-0].vInt; } break; case 74: # line 690 "lua.stx" -{ yyval.vInt = yypvt[-1].vInt; flush_record(yypvt[-1].vInt%FIELDS_PER_FLUSH); } break; +{ luaY_val.vInt = luaY_pvt[-1].vInt; flush_record(luaY_pvt[-1].vInt%FIELDS_PER_FLUSH); } break; case 75: # line 694 "lua.stx" -{ yyval.vInt = 0; } break; +{ luaY_val.vInt = 0; } break; case 76: # line 696 "lua.stx" -{ yyval.vInt = yypvt[-0].vInt; flush_record(yypvt[-0].vInt%FIELDS_PER_FLUSH); } break; +{ luaY_val.vInt = luaY_pvt[-0].vInt; flush_record(luaY_pvt[-0].vInt%FIELDS_PER_FLUSH); } break; case 79: # line 703 "lua.stx" -{ yyval.vInt = 0; } break; +{ luaY_val.vInt = 0; } break; case 80: # line 704 "lua.stx" -{ yyval.vInt = yypvt[-1].vInt; } break; +{ luaY_val.vInt = luaY_pvt[-1].vInt; } break; case 81: # line 707 "lua.stx" -{yyval.vInt=1;} break; +{luaY_val.vInt=1;} break; case 82: # line 709 "lua.stx" { - yyval.vInt=yypvt[-2].vInt+1; - if (yyval.vInt%FIELDS_PER_FLUSH == 0) flush_record(FIELDS_PER_FLUSH); + luaY_val.vInt=luaY_pvt[-2].vInt+1; + if (luaY_val.vInt%FIELDS_PER_FLUSH == 0) flush_record(FIELDS_PER_FLUSH); } break; case 83: # line 716 "lua.stx" { - push_field(luaI_findconstant(yypvt[-2].pNode)); + push_field(luaI_findconstant(luaY_pvt[-2].pTStr)); } break; case 84: # line 721 "lua.stx" -{ yyval.vInt = 0; } break; +{ luaY_val.vInt = 0; } break; case 85: # line 722 "lua.stx" -{ yyval.vInt = yypvt[-1].vInt; } break; +{ luaY_val.vInt = luaY_pvt[-1].vInt; } break; case 86: # line 725 "lua.stx" -{yyval.vInt=1;} break; +{luaY_val.vInt=1;} break; 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); + luaY_val.vInt=luaY_pvt[-2].vInt+1; + if (luaY_val.vInt%FIELDS_PER_FLUSH == 0) + flush_list(luaY_val.vInt/FIELDS_PER_FLUSH - 1, FIELDS_PER_FLUSH); } break; case 88: # line 735 "lua.stx" { nvarbuffer = 0; - add_varbuffer(yypvt[-0].vLong); - yyval.vInt = (yypvt[-0].vLong == 0) ? 1 : 0; + add_varbuffer(luaY_pvt[-0].vLong); + luaY_val.vInt = (luaY_pvt[-0].vLong == 0) ? 1 : 0; } break; case 89: # line 741 "lua.stx" { - add_varbuffer(yypvt[-0].vLong); - yyval.vInt = (yypvt[-0].vLong == 0) ? yypvt[-2].vInt + 1 : yypvt[-2].vInt; + add_varbuffer(luaY_pvt[-0].vLong); + luaY_val.vInt = (luaY_pvt[-0].vLong == 0) ? luaY_pvt[-2].vInt + 1 : luaY_pvt[-2].vInt; } break; case 90: # line 747 "lua.stx" -{ yyval.vLong = yypvt[-0].vLong; } break; +{ luaY_val.vLong = luaY_pvt[-0].vLong; } break; case 91: # line 749 "lua.stx" { - yyval.vLong = 0; /* indexed variable */ + luaY_val.vLong = 0; /* indexed variable */ } break; case 92: # line 753 "lua.stx" { code_byte(PUSHSTRING); - code_word(luaI_findconstant(yypvt[-0].pNode)); - yyval.vLong = 0; /* indexed variable */ + code_word(luaI_findconstant(luaY_pvt[-0].pTStr)); + luaY_val.vLong = 0; /* indexed variable */ } break; case 93: # line 761 "lua.stx" { - Word s = luaI_findsymbol(yypvt[-0].pNode); - int local = lua_localname (s); + int local = lua_localname(luaY_pvt[-0].pTStr); if (local == -1) /* global var */ - yyval.vLong = s + 1; /* return positive value */ + luaY_val.vLong = luaI_findsymbol(luaY_pvt[-0].pTStr)+1; /* return positive value */ else - yyval.vLong = -(local+1); /* return negative value */ + luaY_val.vLong = -(local+1); /* return negative value */ } break; case 94: -# line 771 "lua.stx" -{ lua_pushvar(yypvt[-0].vLong); } break; +# line 770 "lua.stx" +{ lua_pushvar(luaY_pvt[-0].vLong); } break; case 95: -# line 774 "lua.stx" -{store_localvar(luaI_findsymbol(yypvt[-0].pNode), 0); yyval.vInt = 1;} break; +# line 773 "lua.stx" +{store_localvar(luaY_pvt[-0].pTStr, 0); luaY_val.vInt = 1;} break; case 96: -# line 776 "lua.stx" +# line 775 "lua.stx" { - store_localvar(luaI_findsymbol(yypvt[-0].pNode), yypvt[-2].vInt); - yyval.vInt = yypvt[-2].vInt+1; + store_localvar(luaY_pvt[-0].pTStr, luaY_pvt[-2].vInt); + luaY_val.vInt = luaY_pvt[-2].vInt+1; } break; case 97: -# line 782 "lua.stx" -{ yyval.vInt = 0; } break; +# line 781 "lua.stx" +{ luaY_val.vInt = 0; } break; case 98: -# line 783 "lua.stx" -{ yyval.vInt = yypvt[-0].vLong; } break; +# line 782 "lua.stx" +{ luaY_val.vInt = luaY_pvt[-0].vLong; } break; case 99: -# line 786 "lua.stx" -{ lua_debug = yypvt[-0].vInt; } break; +# line 785 "lua.stx" +{ lua_debug = luaY_pvt[-0].vInt; } break; } - goto yystack; /* reset registers in driver code */ + goto luaY_stack; /* reset registers in driver code */ } |
