ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

lstx.cpp

Go to the documentation of this file.
00001 /*  A Bison parser, made from lua.stx
00002 by  GNU Bison version 1.25
00003 */
00004 
00005 // generated most closed version (1.25 was available in 11 May 1996) of bison
00006 // before lua 3.1 alpha was published by lhf in 15 Jan 1998 based on
00007 // http://lua-users.org/lists/lua-l/1998-01/msg00023.html
00008 // lua.stx is from RCS source tree from lua.org by lhf on request
00009 // generated by using command: bison -o lstx.c -p luaY_ -d lua.stx
00010 // removed platform depend not used code, formated code too
00011 
00012 #define FORBIDDEN_SYMBOL_EXCEPTION_setjmp
00013 #define FORBIDDEN_SYMBOL_EXCEPTION_longjmp
00014 
00015 #include "engines/grim/lua/lauxlib.h"
00016 #include "engines/grim/lua/ldo.h"
00017 #include "engines/grim/lua/lfunc.h"
00018 #include "engines/grim/lua/llex.h"
00019 #include "engines/grim/lua/lmem.h"
00020 #include "engines/grim/lua/lopcodes.h"
00021 #include "engines/grim/lua/lparser.h"
00022 #include "engines/grim/lua/lstate.h"
00023 #include "engines/grim/lua/lstring.h"
00024 #include "engines/grim/lua/lua.h"
00025 #include "engines/grim/lua/luadebug.h"
00026 #include "engines/grim/lua/lzio.h"
00027 
00028 namespace Grim {
00029 
00030 
00031 #define YYBISON 1  /* Identify Bison output.  */
00032 
00033 #define yyparse luaY_parse
00034 #define yylex luaY_lex
00035 #define yyerror luaY_error
00036 #define yylval luaY_lval
00037 #define yychar luaY_char
00038 #define yydebug luaY_debug
00039 #define yynerrs luaY_nerrs
00040 #define WRONGTOKEN  258
00041 #define NIL 259
00042 #define IF  260
00043 #define THEN    261
00044 #define ELSE    262
00045 #define ELSEIF  263
00046 #define WHILE   264
00047 #define DO  265
00048 #define REPEAT  266
00049 #define UNTIL   267
00050 #define END 268
00051 #define RETURN  269
00052 #define LOCAL   270
00053 #define FUNCTION    271
00054 #define DOTS    272
00055 #define NUMBER  273
00056 #define NAME    274
00057 #define STRING  275
00058 #define AND 276
00059 #define OR  277
00060 #define EQ  278
00061 #define NE  279
00062 #define LE  280
00063 #define GE  281
00064 #define CONC    282
00065 #define UNARY   283
00066 #define NOT 284
00067 
00068 /*
00069 ** $Id$
00070 ** Syntax analizer and code generator
00071 ** See Copyright Notice in lua.h
00072 */
00073 
00074 
00075 int luaY_parse (void);
00076 
00077 
00078 #define MES_LIM(x)  "(limit=" x ")"
00079 
00080 
00081 /* size of a "normal" jump instruction: OpCode + 1 byte */
00082 #define JMPSIZE 2
00083 
00084 /* maximum number of local variables */
00085 #define MAXLOCALS 32
00086 #define SMAXLOCALS "32"
00087 
00088 #define MINGLOBAL (MAXLOCALS+1)
00089 
00090 /* maximum number of variables in a multiple assignment */
00091 #define MAXVAR 32
00092 #define SMAXVAR "32"
00093 
00094 /* maximum number of nested functions */
00095 #define MAXSTATES  6
00096 #define SMAXSTATES  "6"
00097 
00098 /* maximum number of upvalues */
00099 #define MAXUPVALUES 16
00100 #define SMAXUPVALUES "16"
00101 
00102 
00103 
00104 /*
00105 ** Variable descriptor:
00106 ** if 0<n<MINGLOBAL, represents local variable indexed by (n-1);
00107 ** if MINGLOBAL<=n, represents global variable at position (n-MINGLOBAL);
00108 ** if n<0, indexed variable with index (-n)-1 (table on top of stack);
00109 ** if n==0, an indexed variable (table and index on top of stack)
00110 ** Must be long to store negative Word values.
00111 */
00112 typedef long vardesc;
00113 
00114 #define isglobal(v) (MINGLOBAL<=(v))
00115 #define globalindex(v)  ((v)-MINGLOBAL)
00116 #define islocal(v)  (0<(v) && (v)<MINGLOBAL)
00117 #define localindex(v)   ((v)-1)
00118 #define isdot(v)    (v<0)
00119 #define dotindex(v) ((-(v))-1)
00120 
00121 /* state needed to generate code for a given function */
00122 typedef struct FuncState {
00123     TProtoFunc *f;  /* current function header */
00124     int pc;  /* next position to code */
00125     TaggedString *localvar[MAXLOCALS];  /* store local variable names */
00126     int stacksize;  /* number of values on activation register */
00127     int maxstacksize;  /* maximum number of values on activation register */
00128     int nlocalvar;  /* number of active local variables */
00129     int nupvalues;  /* number of upvalues */
00130     int nvars;  /* number of entries in f->locvars */
00131     int maxcode;  /* size of f->code */
00132     int maxvars;  /* size of f->locvars (-1 if no debug information) */
00133     int maxconsts;  /* size of f->consts */
00134     vardesc varbuffer[MAXVAR];  /* variables in an assignment list */
00135     vardesc upvalues[MAXUPVALUES];  /* upvalues */
00136 } FuncState;
00137 
00138 
00139 
00140 #define YYPURE  1
00141 
00142 
00143 void luaY_syntaxerror (const char *s, const char *token)
00144 {
00145     if (token[0] == 0)
00146         token = "<eof>";
00147     luaL_verror("%.100s;\n  last token read: \"%.50s\" at line %d in file %.50s",
00148         s, token, lua_state->lexstate->linenumber, lua_state->mainState->f->fileName->str);
00149 }
00150 
00151 
00152 void luaY_error (const char *s)
00153 {
00154     luaY_syntaxerror(s, luaX_lasttoken());
00155 }
00156 
00157 
00158 static void check_pc (int n)
00159 {
00160     FuncState *fs = lua_state->currState;
00161     if (fs->pc+n > fs->maxcode)
00162         fs->maxcode = luaM_growvector(&fs->f->code, fs->maxcode,
00163         byte, codeEM, MAX_INT);
00164 }
00165 
00166 
00167 static void code_byte (byte c)
00168 {
00169     check_pc(1);
00170     lua_state->currState->f->code[lua_state->currState->pc++] = c;
00171 }
00172 
00173 
00174 static void deltastack (int delta)
00175 {
00176     FuncState *fs = lua_state->currState;
00177     fs->stacksize += delta;
00178     if (fs->stacksize > fs->maxstacksize) {
00179         if (fs->stacksize > 255)
00180             luaY_error("function/expression too complex");
00181         fs->maxstacksize = fs->stacksize;
00182     }
00183 }
00184 
00185 
00186 static int code_oparg_at (int pc, OpCode op, int builtin, int arg, int delta)
00187 {
00188     byte *code = lua_state->currState->f->code;
00189     deltastack(delta);
00190     if (arg < builtin) {
00191         code[pc] = op+1+arg;
00192         return 1;
00193     }
00194     else if (arg <= 255) {
00195         code[pc] = op;
00196         code[pc+1] = arg;
00197         return 2;
00198     }
00199     else if (arg <= (int)MAX_WORD) {
00200         code[pc] = op+1+builtin;
00201         code[pc+1] = arg&0xFF;
00202         code[pc+2] = arg>>8;
00203         return 3;
00204     }
00205     else luaY_error("code too long " MES_LIM("64K"));
00206     return 0;   /* to avoid warnings */
00207 }
00208 
00209 
00210 static int fix_opcode (int pc, OpCode op, int builtin, int arg)
00211 {
00212     FuncState *fs = lua_state->currState;
00213     if (arg < builtin) {  /* close space */
00214         luaO_memdown(fs->f->code+pc+1, fs->f->code+pc+2, fs->pc-(pc+2));
00215         fs->pc--;
00216     }
00217     else if (arg > 255) {  /* open space */
00218         check_pc(1);
00219         luaO_memup(fs->f->code+pc+1, fs->f->code+pc, fs->pc-pc);
00220         fs->pc++;
00221     }
00222     return code_oparg_at(pc, op, builtin, arg, 0) - 2;
00223 }
00224 
00225 
00226 static void code_oparg (OpCode op, int builtin, int arg, int delta)
00227 {
00228     check_pc(3);  /* maximum code size */
00229     lua_state->currState->pc += code_oparg_at(lua_state->currState->pc, op, builtin, arg, delta);
00230 }
00231 
00232 
00233 static void code_opcode (OpCode op, int delta)
00234 {
00235     deltastack(delta);
00236     code_byte(op);
00237 }
00238 
00239 
00240 static void code_pop (OpCode op)
00241 {
00242     code_opcode(op, -1);
00243 }
00244 
00245 /* binary operations get 2 arguments and leave one, so they pop one */
00246 #define code_binop(op)  code_pop(op)
00247 
00248 
00249 static void code_neutralop (OpCode op)
00250 {
00251     code_opcode(op, 0);
00252 }
00253 
00254 /* unary operations get 1 argument and leave one, so they are neutral */
00255 #define code_unop(op)   code_neutralop(op)
00256 
00257 
00258 static void code_constant (int c)
00259 {
00260     code_oparg(PUSHCONSTANT, 8, c, 1);
00261 }
00262 
00263 
00264 static int next_constant (FuncState *cs)
00265 {
00266     TProtoFunc *f = cs->f;
00267     if (f->nconsts >= cs->maxconsts) {
00268         cs->maxconsts = luaM_growvector(&f->consts, cs->maxconsts, TObject,
00269             constantEM, MAX_WORD);
00270     }
00271     return f->nconsts++;
00272 }
00273 
00274 
00275 static int string_constant (TaggedString *s, FuncState *cs)
00276 {
00277     TProtoFunc *f = cs->f;
00278     int c = s->constindex;
00279     if (!(c < f->nconsts &&
00280         ttype(&f->consts[c]) == LUA_T_STRING && tsvalue(&f->consts[c]) == s)) {
00281             c = next_constant(cs);
00282             ttype(&f->consts[c]) = LUA_T_STRING;
00283             tsvalue(&f->consts[c]) = s;
00284             s->constindex = c;  /* hint for next time */
00285     }
00286     return c;
00287 }
00288 
00289 
00290 static void code_string (TaggedString *s)
00291 {
00292     code_constant(string_constant(s, lua_state->currState));
00293 }
00294 
00295 
00296 #define LIM 20
00297 static int real_constant(float r)
00298 {
00299     /* check whether 'r' has appeared within the last LIM entries */
00300     TObject *cnt = lua_state->currState->f->consts;
00301     int c = lua_state->currState->f->nconsts;
00302     int lim = c < LIM ? 0 : c-LIM;
00303     while (--c >= lim) {
00304         if (ttype(&cnt[c]) == LUA_T_NUMBER && nvalue(&cnt[c]) == r)
00305             return c;
00306     }
00307     /* not found; create a luaM_new entry */
00308     c = next_constant(lua_state->currState);
00309     cnt = lua_state->currState->f->consts;  /* 'next_constant' may reallocate this vector */
00310     ttype(&cnt[c]) = LUA_T_NUMBER;
00311     nvalue(&cnt[c]) = r;
00312     return c;
00313 }
00314 
00315 
00316 static void code_number(float f)
00317 {
00318     int i;
00319     if (f >= 0 && f <= (float)MAX_WORD && (float)(i=(int)f) == f)
00320         code_oparg(PUSHNUMBER, 3, i, 1);  /* f has an (short) integer value */
00321     else
00322         code_constant(real_constant(f));
00323 }
00324 
00325 
00326 static void flush_record (int n)
00327 {
00328     if (n > 0)
00329         code_oparg(SETMAP, 1, n-1, -2*n);
00330 }
00331 
00332 static void flush_list (int m, int n)
00333 {
00334     if (n == 0) return;
00335     code_oparg(SETLIST, 1, m, -n);
00336     code_byte(n);
00337 }
00338 
00339 
00340 static void luaI_registerlocalvar (TaggedString *varname, int line)
00341 {
00342     FuncState *fs = lua_state->currState;
00343     if (fs->maxvars != -1) {  /* debug information? */
00344         if (fs->nvars >= fs->maxvars)
00345             fs->maxvars = luaM_growvector(&fs->f->locvars, fs->maxvars,
00346             LocVar, "", MAX_WORD);
00347         fs->f->locvars[fs->nvars].varname = varname;
00348         fs->f->locvars[fs->nvars].line = line;
00349         fs->nvars++;
00350     }
00351 }
00352 
00353 
00354 static void luaI_unregisterlocalvar (int line)
00355 {
00356     luaI_registerlocalvar(nullptr, line);
00357 }
00358 
00359 
00360 static void store_localvar (TaggedString *name, int n)
00361 {
00362     if (lua_state->currState->nlocalvar+n < MAXLOCALS)
00363         lua_state->currState->localvar[lua_state->currState->nlocalvar+n] = name;
00364     else
00365         luaY_error("too many local variables " MES_LIM(SMAXLOCALS));
00366     luaI_registerlocalvar(name, lua_state->lexstate->linenumber);
00367 }
00368 
00369 static void add_localvar (TaggedString *name)
00370 {
00371     store_localvar(name, 0);
00372     lua_state->currState->nlocalvar++;
00373 }
00374 
00375 
00376 /*
00377 ** dotted variables <a.x> must be stored like regular indexed vars <a["x"]>
00378 */
00379 static vardesc var2store (vardesc var)
00380 {
00381     if (isdot(var)) {
00382         code_constant(dotindex(var));
00383         var = 0;
00384     }
00385     return var;
00386 }
00387 
00388 
00389 static void add_varbuffer (vardesc var, int n)
00390 {
00391     if (n >= MAXVAR)
00392         luaY_error("variable buffer overflow " MES_LIM(SMAXVAR));
00393     lua_state->currState->varbuffer[n] = var2store(var);
00394 }
00395 
00396 
00397 static int aux_localname (TaggedString *n, FuncState *st)
00398 {
00399     int i;
00400     for (i=st->nlocalvar-1; i >= 0; i--)
00401         if (n == st->localvar[i]) return i;  /* local var index */
00402     return -1;  /* not found */
00403 }
00404 
00405 
00406 static vardesc singlevar (TaggedString *n, FuncState *st)
00407 {
00408     int i = aux_localname(n, st);
00409     if (i == -1) {  /* check shadowing */
00410         int l;
00411         for (l=1; l<=(st-lua_state->mainState); l++)
00412             if (aux_localname(n, st-l) >= 0)
00413                 luaY_syntaxerror("cannot access a variable in outer scope", n->str);
00414         return string_constant(n, st)+MINGLOBAL;  /* global value */
00415     }
00416     else return i+1;  /* local value */
00417 }
00418 
00419 
00420 static int indexupvalue (TaggedString *n)
00421 {
00422     vardesc v = singlevar(n, lua_state->currState-1);
00423     int i;
00424     for (i=0; i<lua_state->currState->nupvalues; i++) {
00425         if (lua_state->currState->upvalues[i] == v)
00426             return i;
00427     }
00428     /* new one */
00429     if (++(lua_state->currState->nupvalues) > MAXUPVALUES)
00430         luaY_error("too many upvalues in a single function " MES_LIM(SMAXUPVALUES));
00431     lua_state->currState->upvalues[i] = v;  /* i = lua_state->currState->nupvalues - 1 */
00432     return i;
00433 }
00434 
00435 
00436 static void pushupvalue (TaggedString *n)
00437 {
00438     int i;
00439     if (lua_state->currState == lua_state->mainState)
00440         luaY_error("cannot access upvalue in main");
00441     if (aux_localname(n, lua_state->currState) >= 0)
00442         luaY_syntaxerror("cannot access an upvalue in current scope", n->str);
00443     i = indexupvalue(n);
00444     code_oparg(PUSHUPVALUE, 2, i, 1);
00445 }
00446 
00447 
00448 void luaY_codedebugline (int32 line)
00449 {
00450     if (lua_debug && line != lua_state->lexstate->lastline) {
00451         code_oparg(SETLINE, 0, line, 0);
00452         lua_state->lexstate->lastline = line;
00453     }
00454 }
00455 
00456 
00457 static void adjuststack (int n)
00458 {
00459     if (n > 0)
00460         code_oparg(POP, 2, n-1, -n);
00461     else if (n < 0)
00462         code_oparg(PUSHNIL, 1, (-n)-1, -n);
00463 }
00464 
00465 
00466 static long adjust_functioncall (long exp, int nresults)
00467 {
00468     if (exp <= 0)
00469         return -exp; /* exp is -list length */
00470     else {
00471         int temp = lua_state->currState->f->code[exp];
00472         int nparams = lua_state->currState->f->code[exp-1];
00473         exp += fix_opcode(exp-2, CALLFUNC, 2, nresults);
00474         lua_state->currState->f->code[exp] = nparams;
00475         if (nresults != MULT_RET)
00476             deltastack(nresults);
00477         deltastack(-(nparams+1));
00478         return temp+nresults;
00479     }
00480 }
00481 
00482 
00483 static void adjust_mult_assign (int vars, long exps)
00484 {
00485     if (exps > 0) { /* must correct function call */
00486         int diff = lua_state->currState->f->code[exps] - vars;
00487         if (diff < 0)
00488             adjust_functioncall(exps, -diff);
00489         else {
00490             adjust_functioncall(exps, 0);
00491             adjuststack(diff);
00492         }
00493     }
00494     else adjuststack((-exps)-vars);
00495 }
00496 
00497 
00498 static void code_args (int nparams, int dots)
00499 {
00500     lua_state->currState->nlocalvar += nparams;  /* "self" may already be there */
00501     nparams = lua_state->currState->nlocalvar;
00502     if (!dots) {
00503         lua_state->currState->f->code[1] = nparams;  /* fill-in arg information */
00504         deltastack(nparams);
00505     }
00506     else {
00507         lua_state->currState->f->code[1] = nparams+ZEROVARARG;
00508         deltastack(nparams+1);
00509         add_localvar(luaS_new("arg"));
00510     }
00511 }
00512 
00513 
00514 static void lua_pushvar (vardesc var)
00515 {
00516     if (isglobal(var))
00517         code_oparg(GETGLOBAL, 8, globalindex(var), 1);
00518     else if (islocal(var))
00519         code_oparg(PUSHLOCAL, 8, localindex(var), 1);
00520     else if (isdot(var))
00521         code_oparg(GETDOTTED, 8, dotindex(var), 0);
00522     else
00523         code_pop(GETTABLE);
00524 }
00525 
00526 
00527 static void storevar (vardesc var)
00528 {
00529     if (var == 0)  /* indexed var */
00530         code_opcode(SETTABLE0, -3);
00531     else if (isglobal(var))
00532         code_oparg(SETGLOBAL, 8, globalindex(var), -1);
00533     else  /* local var */
00534         code_oparg(SETLOCAL, 8, localindex(var), -1);
00535 }
00536 
00537 
00538 /* returns how many elements are left as 'garbage' on the stack */
00539 static int lua_codestore (int i, int left)
00540 {
00541     if (lua_state->currState->varbuffer[i] != 0 ||  /* global or local var or */
00542         left+i == 0) {  /* indexed var without values in between */
00543             storevar(lua_state->currState->varbuffer[i]);
00544             return left;
00545     }
00546     else {  /* indexed var with values in between*/
00547         code_oparg(SETTABLE, 0, left+i, -1);
00548         return left+2;  /* table/index are not popped, since they are not on top */
00549     }
00550 }
00551 
00552 
00553 static int fix_jump (int pc, OpCode op, int n)
00554 {
00555     /* jump is relative to position following jump instruction */
00556     return fix_opcode(pc, op, 0, n-(pc+JMPSIZE));
00557 }
00558 
00559 
00560 static void fix_upjmp (OpCode op, int pos)
00561 {
00562     int delta = lua_state->currState->pc+JMPSIZE - pos;  /* jump is relative */
00563     if (delta > 255) delta++;
00564     code_oparg(op, 0, delta, 0);
00565 }
00566 
00567 
00568 static void codeIf (int thenAdd, int elseAdd)
00569 {
00570     int elseinit = elseAdd+JMPSIZE;
00571     if (lua_state->currState->pc == elseinit) {  /* no else part */
00572         lua_state->currState->pc -= JMPSIZE;
00573         elseinit = lua_state->currState->pc;
00574     }
00575     else
00576         elseinit += fix_jump(elseAdd, JMP, lua_state->currState->pc);
00577     fix_jump(thenAdd, IFFJMP, elseinit);
00578 }
00579 
00580 
00581 static void code_shortcircuit (int pc, OpCode op)
00582 {
00583     fix_jump(pc, op, lua_state->currState->pc);
00584 }
00585 
00586 
00587 static void codereturn (void)
00588 {
00589     code_oparg(RETCODE, 0, lua_state->currState->nlocalvar, 0);
00590     lua_state->currState->stacksize = lua_state->currState->nlocalvar;
00591 }
00592 
00593 
00594 static void func_onstack (TProtoFunc *f)
00595 {
00596     int i;
00597     int nupvalues = (lua_state->currState+1)->nupvalues;
00598     int c = next_constant(lua_state->currState);
00599     ttype(&lua_state->currState->f->consts[c]) = LUA_T_PROTO;
00600     lua_state->currState->f->consts[c].value.tf = (lua_state->currState+1)->f;
00601     if (nupvalues == 0)
00602         code_constant(c);
00603     else {
00604         for (i=0; i<nupvalues; i++)
00605             lua_pushvar((lua_state->currState+1)->upvalues[i]);
00606         code_constant(c);
00607         code_oparg(CLOSURE, 2, nupvalues, -nupvalues);
00608     }
00609 }
00610 
00611 
00612 static void init_state (TaggedString *filename) {
00613     TProtoFunc *f = luaF_newproto();
00614     FuncState *fs = lua_state->currState;
00615     fs->stacksize = 0;
00616     fs->maxstacksize = 0;
00617     fs->nlocalvar = 0;
00618     fs->nupvalues = 0;
00619     fs->f = f;
00620     f->fileName = filename;
00621     fs->pc = 0;
00622     fs->maxcode = 0;
00623     f->code = nullptr;
00624     fs->maxconsts = 0;
00625     if (lua_debug) {
00626         fs->nvars = 0;
00627         fs->maxvars = 0;
00628     }
00629     else
00630         fs->maxvars = -1;  /* flag no debug information */
00631     code_byte(0);  /* to be filled with stacksize */
00632     code_byte(0);  /* to be filled with arg information */
00633     lua_state->lexstate->lastline = 0;  /* invalidate it */
00634 }
00635 
00636 static void init_func() {
00637     if (lua_state->currState-lua_state->mainState >= MAXSTATES-1)
00638         luaY_error("too many nested functions " MES_LIM(SMAXSTATES));
00639     lua_state->currState++;
00640     init_state(lua_state->mainState->f->fileName);
00641     luaY_codedebugline(lua_state->lexstate->linenumber);
00642     lua_state->currState->f->lineDefined = lua_state->lexstate->linenumber;
00643 }
00644 
00645 static TProtoFunc *close_func() {
00646     TProtoFunc *f = lua_state->currState->f;
00647     code_neutralop(ENDCODE);
00648     f->code[0] = lua_state->currState->maxstacksize;
00649     f->code = luaM_reallocvector(f->code, lua_state->currState->pc, byte);
00650     f->consts = luaM_reallocvector(f->consts, f->nconsts, TObject);
00651     if (lua_state->currState->maxvars != -1) {  /* debug information? */
00652         luaI_registerlocalvar(nullptr, -1);  /* flag end of vector */
00653         f->locvars = luaM_reallocvector(f->locvars, lua_state->currState->nvars, LocVar);
00654     }
00655     lua_state->currState--;
00656     return f;
00657 }
00658 
00659 
00660 /*
00661 ** Parse Lua code.
00662 */
00663 TProtoFunc *luaY_parser (ZIO *z) {
00664     struct LexState lexstate;
00665     FuncState state[MAXSTATES];
00666     lua_state->currState = lua_state->mainState = &state[0];
00667     lua_state->lexstate = &lexstate;
00668     luaX_setinput(z);
00669     init_state(luaS_new(zname(z)));
00670     if (luaY_parse())
00671         lua_error("parse error");
00672     return close_func();
00673 }
00674 
00675 typedef union {
00676     int vInt;
00677     float vReal;
00678     char *pChar;
00679     long vLong;
00680     TaggedString *pTStr;
00681     TProtoFunc *pFunc;
00682 } YYSTYPE;
00683 
00684 #define YYFINAL     181
00685 #define YYFLAG      -32768
00686 #define YYNTBASE    49
00687 
00688 #define YYTRANSLATE(x) ((unsigned)(x) <= 284 ? yytranslate[x] : 93)
00689 
00690 static const char yytranslate[] = {     0,
00691 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00692 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00693 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00694 2,     2,     2,     2,     2,     2,    43,     2,     2,    41,
00695 42,    32,    30,    48,    31,    39,    33,     2,     2,     2,
00696 2,     2,     2,     2,     2,     2,     2,    40,    37,    26,
00697 38,    25,     2,     2,     2,     2,     2,     2,     2,     2,
00698 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00699 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00700 44,     2,    45,    36,     2,     2,     2,     2,     2,     2,
00701 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00702 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00703 2,     2,    46,     2,    47,     2,     2,     2,     2,     2,
00704 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00705 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00706 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00707 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00708 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00709 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00710 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00711 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00712 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00713 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00714 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00715 2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00716 2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
00717 6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
00718 16,    17,    18,    19,    20,    21,    22,    23,    24,    27,
00719 28,    29,    34,    35
00720 };
00721 
00722 static const short yyr1[] = {     0,
00723 49,    50,    50,    51,    51,    52,    52,    52,    52,    52,
00724 52,    52,    52,    54,    53,    55,    55,    55,    56,    57,
00725 58,    59,    59,    59,    60,    60,    61,    62,    63,    64,
00726 65,    66,    67,    67,    67,    67,    67,    67,    67,    67,
00727 67,    67,    67,    67,    67,    67,    67,    67,    67,    67,
00728 67,    67,    68,    67,    67,    67,    69,    70,    70,    70,
00729 71,    71,    71,    72,    73,    74,    75,    75,    76,    76,
00730 76,    77,    77,    78,    79,    78,    80,    80,    80,    80,
00731 81,    81,    82,    82,    82,    83,    83,    84,    85,    86,
00732 86,    87,    88,    88,    89,    89,    90,    90,    91,    91,
00733 92,    92
00734 };
00735 
00736 static const short yyr2[] = {     0,
00737 2,     0,     3,     0,     1,     7,     3,     6,     5,     3,
00738 1,     3,     3,     0,     2,     1,     3,     3,     1,     1,
00739 5,     0,     2,     6,     0,     3,     0,     0,     1,     1,
00740 2,     1,     3,     3,     3,     3,     3,     3,     3,     3,
00741 3,     3,     3,     3,     3,     2,     2,     1,     1,     1,
00742 1,     1,     0,     3,     4,     4,     1,     1,     2,     1,
00743 1,     4,     3,     1,     4,     2,     1,     3,     3,     1,
00744 1,     0,     1,     1,     0,     4,     0,     1,     1,     3,
00745 1,     3,     0,     1,     1,     0,     1,     2,     2,     1,
00746 3,     3,     3,     1,     1,     3,     1,     3,     1,     3,
00747 0,     2
00748 };
00749 
00750 static const short yydefact[] = {     2,
00751 25,     0,    27,    14,    27,    72,     0,     0,    64,     0,
00752 4,     1,    67,    57,    58,    61,    11,     0,     0,    52,
00753 53,    50,    51,     0,     0,     0,    28,     0,    28,    32,
00754 48,    58,    49,    60,     0,     0,     2,    14,     0,    74,
00755 4,    73,    99,   101,     0,     0,    19,    59,     5,     3,
00756 0,     0,     0,    71,    72,    70,    66,     0,     0,     0,
00757 46,    47,    32,    30,    83,    14,    28,    28,     0,     0,
00758 0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
00759 29,    31,     0,     7,    15,     0,    26,    75,     0,     0,
00760 12,    77,    13,     0,     0,    63,    68,     0,     0,    10,
00761 58,    54,    33,    64,     0,    94,    95,     0,    81,    84,
00762 85,    86,    90,     0,    86,    28,     0,     0,    34,    37,
00763 36,    35,    38,    39,    45,    40,    41,    42,    43,    44,
00764 14,     0,     0,   102,   100,    78,     0,    79,    20,    17,
00765 18,    62,    69,     0,    65,    83,    87,    88,     0,    87,
00766 89,    22,    55,    56,     0,     9,    76,     2,     0,    93,
00767 82,    91,    92,    96,    14,     0,     0,     8,     0,    80,
00768 23,     0,     6,    21,    14,    28,    22,    24,     0,     0,
00769 0
00770 };
00771 
00772 static const short yydefgoto[] = {    85,
00773 1,    50,    11,    36,    37,    45,    46,   106,    93,   167,
00774 12,    35,    81,    82,    65,    28,    39,    30,    60,    13,
00775 31,    32,    16,    33,    34,    18,    57,    41,    42,   133,
00776 137,   108,   109,   148,   110,   111,   112,   113,   114,   115,
00777 19,    44,    91
00778 };
00779 
00780 static const short yypact[] = {-32768,
00781 147,    94,-32768,-32768,-32768,    94,    19,    34,-32768,    39,
00782 -19,-32768,     2,-32768,   -29,-32768,   -10,    -6,   -27,-32768,
00783 -32768,-32768,-32768,    94,    94,    94,-32768,    14,   196,-32768,
00784 4,-32768,-32768,-32768,    94,    49,-32768,-32768,   196,   212,
00785 -19,    18,-32768,   -22,    38,    21,    40,-32768,-32768,-32768,
00786 68,    71,    94,-32768,    94,-32768,-32768,    94,     9,    38,
00787 57,    57,    62,-32768,    76,-32768,-32768,-32768,    94,    94,
00788 94,    94,    94,    94,    94,    94,    94,    94,    94,    94,
00789 -32768,-32768,    96,-32768,-32768,   106,-32768,-32768,    94,   102,
00790 -32768,    -4,-32768,   109,   109,-32768,-32768,   146,    91,    18,
00791 -21,-32768,-32768,    98,    94,-32768,   196,    92,   105,-32768,
00792 -32768,    90,-32768,   107,    95,-32768,    94,    94,    53,    53,
00793 53,    53,    53,    53,    69,    23,    23,    57,    57,    57,
00794 -32768,    94,    94,    18,-32768,-32768,   104,   112,-32768,-32768,
00795 -32768,-32768,-32768,   171,-32768,    76,    -7,-32768,    94,    94,
00796 -32768,   101,   226,   226,   136,   196,   212,-32768,    30,-32768,
00797 -32768,-32768,   196,   196,-32768,    94,   137,-32768,   140,-32768,
00798 -32768,   148,-32768,-32768,-32768,-32768,   101,-32768,   155,   165,
00799 -32768
00800 };
00801 
00802 static const short yypgoto[] = {     1,
00803 -32768,   139,-32768,   -34,-32768,-32768,-32768,    29,   121,     7,
00804 -32768,   178,   -25,    59,-32768,   -32,    -2,    -1,-32768,-32768,
00805 5,     6,   177,   168,   186,-32768,-32768,   133,   -50,-32768,
00806 -32768,-32768,    43,    93,-32768,-32768,-32768,    58,-32768,-32768,
00807 -32768,   114,-32768
00808 };
00809 
00810 
00811 #define YYLAST      262
00812 
00813 
00814 static const short yytable[] = {    29,
00815 179,    64,    83,    86,    40,    14,    15,   100,   -97,   -60,
00816 58,   139,   136,    54,    43,    89,   -98,    49,   -97,    66,
00817 59,    61,    62,   -57,    63,    90,   -98,     9,   -60,   -60,
00818 -60,   116,    29,   -60,    55,   -60,   105,    43,   134,    27,
00819 51,    52,   -57,   -57,   -57,    53,   170,   -57,   135,   -57,
00820 98,    10,     9,    40,    78,    79,    40,    48,    80,    94,
00821 95,    84,   107,    14,   101,    88,   119,   120,   121,   122,
00822 123,   124,   125,   126,   127,   128,   129,   130,    92,    20,
00823 -16,    75,    76,    77,    78,    79,    96,    40,    80,    97,
00824 152,    21,    80,    22,   104,    23,   155,    20,    76,    77,
00825 78,    79,   144,   103,    80,   131,    24,   165,   166,    21,
00826 25,    22,     9,    23,   153,   154,    26,   132,    10,   105,
00827 135,    27,   140,   141,    24,   117,   118,   139,    25,   156,
00828 171,   157,   143,   172,    26,   -20,    10,   147,   145,    27,
00829 176,   146,   150,   107,   149,   158,   163,   164,   168,   173,
00830 177,     2,   174,   175,   180,     3,     4,     5,   169,   159,
00831 6,     7,     8,    29,   181,     9,    67,    68,    69,    70,
00832 71,    72,    73,    74,    75,    76,    77,    78,    79,    87,
00833 102,    80,    38,   178,    47,    56,    17,    99,   161,    10,
00834 142,    67,    68,    69,    70,    71,    72,    73,    74,    75,
00835 76,    77,    78,    79,   162,   138,    80,   151,     0,     0,
00836 0,     0,     0,     0,     0,   160,    67,    68,    69,    70,
00837 71,    72,    73,    74,    75,    76,    77,    78,    79,     0,
00838 0,    80,   -32,   -32,   -32,   -32,   -32,   -32,   -32,   -32,
00839 -32,   -32,   -32,   -32,   -32,     0,     0,   -32,    69,    70,
00840 71,    72,    73,    74,    75,    76,    77,    78,    79,     0,
00841 0,    80
00842 };
00843 
00844 static const short yycheck[] = {     2,
00845 0,    27,    35,    38,     6,     1,     1,    58,    38,    20,
00846 38,    19,    17,    20,    19,    38,    38,    37,    48,     6,
00847 48,    24,    25,    20,    26,    48,    48,    19,    39,    40,
00848 41,    66,    35,    44,    41,    46,    44,    19,    89,    46,
00849 39,    40,    39,    40,    41,    44,    17,    44,    19,    46,
00850 53,    43,    19,    55,    32,    33,    58,    19,    36,    39,
00851 40,    13,    65,    59,    59,    48,    69,    70,    71,    72,
00852 73,    74,    75,    76,    77,    78,    79,    80,    41,     4,
00853 41,    29,    30,    31,    32,    33,    19,    89,    36,    19,
00854 116,    16,    36,    18,    19,    20,   131,     4,    30,    31,
00855 32,    33,   105,    42,    36,    10,    31,     7,     8,    16,
00856 35,    18,    19,    20,   117,   118,    41,    12,    43,    44,
00857 19,    46,    94,    95,    31,    67,    68,    19,    35,   132,
00858 165,   133,    42,   166,    41,    38,    43,    48,    47,    46,
00859 175,    37,    48,   146,    38,    42,   149,   150,    13,    13,
00860 176,     5,    13,     6,     0,     9,    10,    11,   158,    48,
00861 14,    15,    16,   166,     0,    19,    21,    22,    23,    24,
00862 25,    26,    27,    28,    29,    30,    31,    32,    33,    41,
00863 60,    36,     5,   177,     8,    18,     1,    55,   146,    43,
00864 45,    21,    22,    23,    24,    25,    26,    27,    28,    29,
00865 30,    31,    32,    33,   147,    92,    36,   115,    -1,    -1,
00866 -1,    -1,    -1,    -1,    -1,    45,    21,    22,    23,    24,
00867 25,    26,    27,    28,    29,    30,    31,    32,    33,    -1,
00868 -1,    36,    21,    22,    23,    24,    25,    26,    27,    28,
00869 29,    30,    31,    32,    33,    -1,    -1,    36,    23,    24,
00870 25,    26,    27,    28,    29,    30,    31,    32,    33,    -1,
00871 -1,    36
00872 };
00873 
00874 /* Skeleton output parser for bison,
00875 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
00876 
00877 This program is free software; you can redistribute it and/or modify
00878 it under the terms of the GNU General Public License as published by
00879 the Free Software Foundation; either version 2, or (at your option)
00880 any later version.
00881 
00882 This program is distributed in the hope that it will be useful,
00883 but WITHOUT ANY WARRANTY; without even the implied warranty of
00884 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00885 GNU General Public License for more details.
00886 
00887 You should have received a copy of the GNU General Public License
00888 along with this program; if not, write to the Free Software
00889 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
00890 
00891 /* As a special exception, when this file is copied by Bison into a
00892 Bison output file, you may use that output file without restriction.
00893 This special exception was added by the Free Software Foundation
00894 in version 1.24 of Bison.  */
00895 
00896 /* This is the parser code that is written into each bison parser
00897 when the %semantic_parser declaration is not specified in the grammar.
00898 It was written by Richard Stallman by simplifying the hairy parser
00899 used when %semantic_parser is specified.  */
00900 
00901 /* Note: there must be only one dollar sign in this file.
00902 It is replaced by the list of actions, each action
00903 as one case of the switch.  */
00904 
00905 #define yyerrok     (yyerrstatus = 0)
00906 #define yyclearin   (yychar = YYEMPTY)
00907 #define YYEMPTY     -2
00908 #define YYEOF       0
00909 #define YYACCEPT    return(0)
00910 #define YYABORT     return(1)
00911 #define YYERROR     goto yyerrlab1
00912 /* Like YYERROR except do call yyerror.
00913 This remains here temporarily to ease the
00914 transition to the new meaning of YYERROR, for GCC.
00915 Once GCC version 2 has supplanted version 1, this can go.  */
00916 #define YYFAIL      goto yyerrlab
00917 #define YYRECOVERING()  (!!yyerrstatus)
00918 #define YYBACKUP(token, value) \
00919     do                              \
00920     if (yychar == YYEMPTY && yylen == 1) {              \
00921         yychar = (token), yylval = (value);         \
00922         yychar1 = YYTRANSLATE (yychar);             \
00923         YYPOPSTACK;                     \
00924         goto yybackup;                      \
00925     } else { yyerror ("syntax error: cannot back up"); YYERROR; }   \
00926     while (0)
00927 
00928 #define YYTERROR    1
00929 #define YYERRCODE   256
00930 
00931 #define YYLEX       yylex(&yylval)
00932 
00933 int32 luaY_lex(YYSTYPE *l);
00934 
00935 /* If nonreentrant, generate the variables here */
00936 
00937 #define YYINITDEPTH 1000
00938 
00939 int yyparse() {
00940     register int yystate;
00941     register int yyn;
00942     register short *yyssp;
00943     register YYSTYPE *yyvsp;
00944     int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
00945     int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
00946 
00947     short   yyssa[YYINITDEPTH]; /*  the state stack         */
00948     YYSTYPE yyvsa[YYINITDEPTH]; /*  the semantic value stack        */
00949 
00950     short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
00951     YYSTYPE *yyvs = yyvsa;  /*  to allow yyoverflow to reallocate them elsewhere */
00952 
00953 #define YYPOPSTACK   (yyvsp--, yyssp--)
00954 
00955     int yystacksize = YYINITDEPTH;
00956 
00957     int yychar;
00958     YYSTYPE yylval;
00959     int yynerrs;
00960 
00961     YYSTYPE yyval;      /*  the variable used to return     */
00962     /*  semantic values from the action */
00963     /*  routines                */
00964 
00965     int yylen;
00966 
00967     yystate = 0;
00968     yyerrstatus = 0;
00969     yynerrs = 0;
00970     yychar = YYEMPTY;       /* Cause a token to be read.  */
00971 
00972     /* Initialize stack pointers.
00973     Waste one element of value and location stack
00974     so that they stay on the same level as the state stack.
00975     The wasted elements are never initialized.  */
00976 
00977     yyssp = yyss - 1;
00978     yyvsp = yyvs;
00979 
00980     /* Push a new state, which is found in  yystate  .  */
00981     /* In all cases, when you get here, the value and location stacks
00982     have just been pushed. so pushing a state here evens the stacks.  */
00983 yynewstate:
00984 
00985     *++yyssp = yystate;
00986 
00987     if (yyssp >= yyss + yystacksize - 1) {
00988         yyerror("parser stack overflow");
00989         return 2;
00990     }
00991 
00992     goto yybackup;
00993 yybackup:
00994 
00995     /* Do appropriate processing given the current state.  */
00996     /* Read a lookahead token if we need one and don't already have one.  */
00997     /* yyresume: */
00998 
00999     /* First try to decide what to do without reference to lookahead token.  */
01000 
01001     yyn = yypact[yystate];
01002     if (yyn == YYFLAG)
01003         goto yydefault;
01004 
01005     /* Not known => get a lookahead token if don't already have one.  */
01006 
01007     /* yychar is either YYEMPTY or YYEOF
01008     or a valid token in external form.  */
01009 
01010     if (yychar == YYEMPTY)
01011         yychar = YYLEX;
01012 
01013     /* Convert token to internal form (in yychar1) for indexing tables with */
01014 
01015     if (yychar <= 0) {      /* This means end of input. */
01016         yychar1 = 0;
01017         yychar = YYEOF;     /* Don't call YYLEX any more */
01018     } else {
01019         yychar1 = YYTRANSLATE(yychar);
01020     }
01021 
01022     yyn += yychar1;
01023     if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
01024         goto yydefault;
01025 
01026     yyn = yytable[yyn];
01027 
01028     /* yyn is what to do for this token type in this state.
01029     Negative => reduce, -yyn is rule number.
01030     Positive => shift, yyn is new state.
01031     New state is final state => don't bother to shift,
01032     just return success.
01033     0, or most negative number => error.  */
01034 
01035     if (yyn < 0) {
01036         if (yyn == YYFLAG)
01037             goto yyerrlab;
01038         yyn = -yyn;
01039         goto yyreduce;
01040     } else if (yyn == 0)
01041         goto yyerrlab;
01042 
01043     if (yyn == YYFINAL)
01044         YYACCEPT;
01045 
01046     /* Shift the lookahead token.  */
01047 
01048     /* Discard the token being shifted unless it is eof.  */
01049     if (yychar != YYEOF)
01050         yychar = YYEMPTY;
01051 
01052     *++yyvsp = yylval;
01053 
01054     /* count tokens shifted since error; after three, turn off error status.  */
01055     if (yyerrstatus)
01056         yyerrstatus--;
01057 
01058     yystate = yyn;
01059     goto yynewstate;
01060 
01061     /* Do the default action for the current state.  */
01062 yydefault:
01063 
01064     yyn = yydefact[yystate];
01065     if (yyn == 0)
01066         goto yyerrlab;
01067 
01068     /* Do a reduction.  yyn is the number of a rule to reduce with.  */
01069 yyreduce:
01070     yylen = yyr2[yyn];
01071     if (yylen > 0)
01072         yyval = yyvsp[1 - yylen]; /* implement default value of the action */
01073 
01074     switch (yyn) {
01075 
01076 case 6:
01077     { codeIf(yyvsp[-5].vInt, yyvsp[-2].vInt); ;
01078     break;}
01079 case 8:
01080     {{
01081         FuncState *fs = lua_state->currState;
01082         int expsize = yyvsp[-3].vInt-yyvsp[-4].vInt;
01083         int newpos = yyvsp[-4].vInt+JMPSIZE;
01084         check_pc(expsize);
01085         memcpy(fs->f->code+fs->pc, fs->f->code+yyvsp[-4].vInt, expsize);
01086         luaO_memdown(fs->f->code+yyvsp[-4].vInt, fs->f->code+yyvsp[-3].vInt, fs->pc-yyvsp[-4].vInt);
01087         newpos += fix_jump(yyvsp[-4].vInt, JMP, fs->pc-expsize);
01088         fix_upjmp(IFTUPJMP, newpos);
01089     };
01090     break;}
01091 case 9:
01092     {
01093         fix_upjmp(IFFUPJMP, yyvsp[-3].vInt);
01094         deltastack(-1);  /* pops condition */
01095         ;
01096         break;}
01097 case 10:
01098     {{
01099         int i;
01100         int left = 0;
01101         adjust_mult_assign(yyvsp[-2].vInt, yyvsp[0].vLong);
01102         for (i=yyvsp[-2].vInt-1; i>=0; i--)
01103             left = lua_codestore(i, left);
01104         adjuststack(left);  /* remove eventual 'garbage' left on stack */
01105     };
01106     break;}
01107 case 11:
01108     { adjust_functioncall(yyvsp[0].vLong, 0); ;
01109     break;}
01110 case 12:
01111     {
01112         lua_state->currState->nlocalvar += yyvsp[-1].vInt;
01113         adjust_mult_assign(yyvsp[-1].vInt, yyvsp[0].vInt);
01114         ;
01115         break;}
01116 case 13:
01117     { storevar(yyvsp[-1].vLong); ;
01118     break;}
01119 case 14:
01120     {yyval.vInt = lua_state->currState->nlocalvar;;
01121     break;}
01122 case 15:
01123     {
01124         adjuststack(lua_state->currState->nlocalvar - yyvsp[-1].vInt);
01125         for (; lua_state->currState->nlocalvar > yyvsp[-1].vInt; lua_state->currState->nlocalvar--)
01126             luaI_unregisterlocalvar(lua_state->lexstate->linenumber);
01127         ;
01128         break;}
01129 case 16:
01130     { yyval.vLong = yyvsp[0].vLong; init_func(); ;
01131     break;}
01132 case 17:
01133     {
01134         yyval.vLong = 0;  /* flag indexed variable */
01135         init_func();
01136         ;
01137         break;}
01138 case 18:
01139     {
01140         yyval.vLong = 0;  /* flag indexed variable */
01141         init_func();
01142         add_localvar(luaS_new("self"));
01143         ;
01144         break;}
01145 case 19:
01146     { lua_pushvar(yyvsp[0].vLong); ;
01147     break;}
01148 case 20:
01149     { code_string(yyvsp[0].pTStr); ;
01150     break;}
01151 case 21:
01152     { func_onstack(close_func()); ;
01153     break;}
01154 case 24:
01155     { codeIf(yyvsp[-4].vInt, yyvsp[-1].vInt); ;
01156     break;}
01157 case 26:
01158     {
01159         adjust_functioncall(yyvsp[-1].vLong, MULT_RET);
01160         codereturn();
01161         ;
01162         break;}
01163 case 27:
01164     { yyval.vInt = lua_state->currState->pc; ;
01165     break;}
01166 case 28:
01167     { yyval.vInt = lua_state->currState->pc;
01168     check_pc(JMPSIZE);
01169     lua_state->currState->pc += JMPSIZE;  /* open space */
01170     ;
01171     break;}
01172 case 29:
01173     { yyval.vInt = yyvsp[0].vInt; deltastack(-1);  /* pop condition */ ;
01174     break;}
01175 case 30:
01176     { yyval.vInt = yyvsp[0].vInt; deltastack(1);  /* push a value */ ;
01177     break;}
01178 case 31:
01179     { yyval.vInt = yyvsp[0].vInt; ;
01180     break;}
01181 case 32:
01182     { adjust_functioncall(yyvsp[0].vLong, 1); ;
01183     break;}
01184 case 33:
01185     { yyval.vLong = yyvsp[-1].vLong; ;
01186     break;}
01187 case 34:
01188     { code_binop(EQOP);   yyval.vLong = 0; ;
01189     break;}
01190 case 35:
01191     { code_binop(LTOP);   yyval.vLong = 0; ;
01192     break;}
01193 case 36:
01194     { code_binop(GTOP);   yyval.vLong = 0; ;
01195     break;}
01196 case 37:
01197     { code_binop(NEQOP);  yyval.vLong = 0; ;
01198     break;}
01199 case 38:
01200     { code_binop(LEOP);   yyval.vLong = 0; ;
01201     break;}
01202 case 39:
01203     { code_binop(GEOP);   yyval.vLong = 0; ;
01204     break;}
01205 case 40:
01206     { code_binop(ADDOP);  yyval.vLong = 0; ;
01207     break;}
01208 case 41:
01209     { code_binop(SUBOP);  yyval.vLong = 0; ;
01210     break;}
01211 case 42:
01212     { code_binop(MULTOP); yyval.vLong = 0; ;
01213     break;}
01214 case 43:
01215     { code_binop(DIVOP);  yyval.vLong = 0; ;
01216     break;}
01217 case 44:
01218     { code_binop(POWOP);  yyval.vLong = 0; ;
01219     break;}
01220 case 45:
01221     { code_binop(CONCOP);  yyval.vLong = 0; ;
01222     break;}
01223 case 46:
01224     { code_unop(MINUSOP); yyval.vLong = 0;;
01225     break;}
01226 case 47:
01227     { code_unop(NOTOP);  yyval.vLong = 0;;
01228     break;}
01229 case 48:
01230     { yyval.vLong = yyvsp[0].vLong;  /* simple expressions */ ;
01231     break;}
01232 case 49:
01233     { yyval.vLong = 0; ;
01234     break;}
01235 case 50:
01236     { code_number(yyvsp[0].vReal); yyval.vLong = 0; ;
01237     break;}
01238 case 51:
01239     { code_string(yyvsp[0].pTStr); yyval.vLong = 0; ;
01240     break;}
01241 case 52:
01242     { adjuststack(-1); yyval.vLong = 0; ;
01243     break;}
01244 case 53:
01245     { init_func(); ;
01246     break;}
01247 case 54:
01248     { yyval.vLong = 0; ;
01249     break;}
01250 case 55:
01251     { code_shortcircuit(yyvsp[-1].vInt, ONFJMP); yyval.vLong = 0; ;
01252     break;}
01253 case 56:
01254     { code_shortcircuit(yyvsp[-1].vInt, ONTJMP); yyval.vLong = 0; ;
01255     break;}
01256 case 57:
01257     { adjust_functioncall(yyvsp[0].vLong, 1); ;
01258     break;}
01259 case 58:
01260     { lua_pushvar(yyvsp[0].vLong); yyval.vLong = 0; ;
01261     break;}
01262 case 59:
01263     { pushupvalue(yyvsp[0].pTStr); yyval.vLong = 0; ;
01264     break;}
01265 case 60:
01266     { yyval.vLong = yyvsp[0].vLong; ;
01267     break;}
01268 case 61:
01269     { yyval.vLong = yyvsp[0].vLong; ;
01270     break;}
01271 case 62:
01272     { yyval.vLong = 0; ;
01273     break;}
01274 case 63:
01275     { yyval.vLong = (-string_constant(yyvsp[0].pTStr, lua_state->currState))-1; ;
01276     break;}
01277 case 64:
01278     { yyval.vLong = singlevar(yyvsp[0].pTStr, lua_state->currState); ;
01279     break;}
01280 case 65:
01281     { fix_opcode(yyvsp[-2].vInt, CREATEARRAY, 2, yyvsp[-1].vInt); ;
01282     break;}
01283 case 66:
01284     {
01285         code_byte(0);  /* save space for opcode */
01286         code_byte(yyvsp[-1].vInt+yyvsp[0].vInt);  /* number of parameters */
01287         yyval.vLong = lua_state->currState->pc;
01288         code_byte(0);  /* must be adjusted by other rules */
01289         ;
01290         break;}
01291 case 67:
01292     { yyval.vInt = 0; ;
01293     break;}
01294 case 68:
01295     {
01296         code_oparg(PUSHSELF, 8, string_constant(yyvsp[0].pTStr, lua_state->currState), 1);
01297         yyval.vInt = 1;
01298         ;
01299         break;}
01300 case 69:
01301     { yyval.vInt = adjust_functioncall(yyvsp[-1].vLong, 1); ;
01302     break;}
01303 case 70:
01304     { yyval.vInt = 1; ;
01305     break;}
01306 case 71:
01307     { code_string(yyvsp[0].pTStr); yyval.vInt = 1; ;
01308     break;}
01309 case 72:
01310     { yyval.vLong = 0; ;
01311     break;}
01312 case 73:
01313     { yyval.vLong = yyvsp[0].vLong; ;
01314     break;}
01315 case 74:
01316     { if (yyvsp[0].vLong != 0) yyval.vLong = yyvsp[0].vLong; else yyval.vLong = -1; ;
01317     break;}
01318 case 75:
01319     { yyval.vLong = adjust_functioncall(yyvsp[-1].vLong, 1); ;
01320     break;}
01321 case 76:
01322     {
01323         if (yyvsp[0].vLong == 0) yyval.vLong = -(yyvsp[-1].vLong + 1);  /* -length */
01324         else {
01325             lua_state->currState->f->code[yyvsp[0].vLong] = yyvsp[-1].vLong;  /* store list length */
01326             yyval.vLong = yyvsp[0].vLong;
01327         }
01328         ;
01329         break;}
01330 case 77:
01331     { code_args(0, 0); ;
01332     break;}
01333 case 78:
01334     { code_args(0, 1); ;
01335     break;}
01336 case 79:
01337     { code_args(yyvsp[0].vInt, 0); ;
01338     break;}
01339 case 80:
01340     { code_args(yyvsp[-2].vInt, 1); ;
01341     break;}
01342 case 81:
01343     { yyval.vInt = abs(yyvsp[0].vInt); ;
01344     break;}
01345 case 82:
01346     {
01347         if (yyvsp[-2].vInt*yyvsp[0].vInt > 0)  /* repeated parts? */
01348             luaY_error("invalid constructor syntax");
01349         yyval.vInt = abs(yyvsp[-2].vInt)+abs(yyvsp[0].vInt);
01350         ;
01351         break;}
01352 case 83:
01353     { yyval.vInt = 0; ;
01354     break;}
01355 case 84:
01356     { yyval.vInt = yyvsp[0].vInt; ;
01357     break;}
01358 case 85:
01359     { yyval.vInt = yyvsp[0].vInt; ;
01360     break;}
01361 case 88:
01362     {
01363         flush_record(yyvsp[-1].vInt%RFIELDS_PER_FLUSH);
01364         yyval.vInt = -yyvsp[-1].vInt;  /* negative signals a "record" part */
01365         ;
01366         break;}
01367 case 89:
01368     {
01369         flush_list(yyvsp[-1].vInt/LFIELDS_PER_FLUSH, yyvsp[-1].vInt%LFIELDS_PER_FLUSH);
01370         yyval.vInt = yyvsp[-1].vInt;
01371         ;
01372         break;}
01373 case 90:
01374     {yyval.vInt=1;;
01375     break;}
01376 case 91:
01377     {
01378         yyval.vInt=yyvsp[-2].vInt+1;
01379         if (yyval.vInt%RFIELDS_PER_FLUSH == 0)
01380             flush_record(RFIELDS_PER_FLUSH);
01381         ;
01382         break;}
01383 case 95:
01384     {yyval.vInt=1;;
01385     break;}
01386 case 96:
01387     {
01388         yyval.vInt=yyvsp[-2].vInt+1;
01389         if (yyval.vInt%LFIELDS_PER_FLUSH == 0)
01390             flush_list(yyval.vInt/LFIELDS_PER_FLUSH - 1, LFIELDS_PER_FLUSH);
01391         ;
01392         break;}
01393 case 97:
01394     { yyval.vInt = 1; add_varbuffer(yyvsp[0].vLong, 0); ;
01395     break;}
01396 case 98:
01397     { add_varbuffer(yyvsp[0].vLong, yyvsp[-2].vInt); yyval.vInt = yyvsp[-2].vInt+1; ;
01398     break;}
01399 case 99:
01400     {store_localvar(yyvsp[0].pTStr, 0); yyval.vInt = 1;;
01401     break;}
01402 case 100:
01403     { store_localvar(yyvsp[0].pTStr, yyvsp[-2].vInt); yyval.vInt = yyvsp[-2].vInt+1; ;
01404     break;}
01405 case 101:
01406     { yyval.vInt = 0; ;
01407     break;}
01408 case 102:
01409     { yyval.vInt = yyvsp[0].vLong; ;
01410     break;}
01411     }
01412     /* the action file gets copied in in place of this dollarsign */
01413 
01414     yyvsp -= yylen;
01415     yyssp -= yylen;
01416 
01417     *++yyvsp = yyval;
01418 
01419     /* Now "shift" the result of the reduction.
01420     Determine what state that goes to,
01421     based on the state we popped back to
01422     and the rule number reduced by.  */
01423 
01424     yyn = yyr1[yyn];
01425 
01426     yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
01427     if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
01428         yystate = yytable[yystate];
01429     else
01430         yystate = yydefgoto[yyn - YYNTBASE];
01431 
01432     goto yynewstate;
01433 
01434 yyerrlab:   /* here on detecting error */
01435 
01436     if (! yyerrstatus) {
01437         /* If not already recovering from an error, report this error.  */
01438         ++yynerrs;
01439         yyerror("parse error");
01440     }
01441 
01442     goto yyerrlab1;
01443 yyerrlab1:   /* here on error raised explicitly by an action */
01444 
01445     if (yyerrstatus == 3) {
01446         /* if just tried and failed to reuse lookahead token after an error, discard it.  */
01447 
01448         /* return failure if at end of input */
01449         if (yychar == YYEOF)
01450             YYABORT;
01451 
01452         yychar = YYEMPTY;
01453     }
01454 
01455     /* Else will try to reuse lookahead token
01456     after shifting the error token.  */
01457 
01458     yyerrstatus = 3;        /* Each real token shifted decrements this */
01459 
01460     goto yyerrhandle;
01461 
01462 yyerrdefault:  /* current state does not do anything special for the error token. */
01463 
01464 yyerrpop:   /* pop the current state because it cannot handle the error token */
01465 
01466     if (yyssp == yyss)
01467         YYABORT;
01468     yyvsp--;
01469     yystate = *--yyssp;
01470 
01471 yyerrhandle:
01472 
01473     yyn = yypact[yystate];
01474     if (yyn == YYFLAG)
01475         goto yyerrdefault;
01476 
01477     yyn += YYTERROR;
01478     if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
01479         goto yyerrdefault;
01480 
01481     yyn = yytable[yyn];
01482     if (yyn < 0) {
01483         if (yyn == YYFLAG)
01484             goto yyerrpop;
01485         yyn = -yyn;
01486         goto yyreduce;
01487     } else if (yyn == 0)
01488         goto yyerrpop;
01489 
01490     if (yyn == YYFINAL)
01491         YYACCEPT;
01492 
01493     *++yyvsp = yylval;
01494 
01495     yystate = yyn;
01496     goto yynewstate;
01497 }
01498 
01499 } // end of namespace Grim


Generated on Sat May 18 2019 05:01:07 for ResidualVM by doxygen 1.7.1
curved edge   curved edge