rlm@1: /* rlm@1: ** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ rlm@1: ** Lua Parser rlm@1: ** See Copyright Notice in lua.h rlm@1: */ rlm@1: rlm@1: #ifndef lparser_h rlm@1: #define lparser_h rlm@1: rlm@1: #include "llimits.h" rlm@1: #include "lobject.h" rlm@1: #include "lzio.h" rlm@1: rlm@1: rlm@1: /* rlm@1: ** Expression descriptor rlm@1: */ rlm@1: rlm@1: typedef enum { rlm@1: VVOID, /* no value */ rlm@1: VNIL, rlm@1: VTRUE, rlm@1: VFALSE, rlm@1: VK, /* info = index of constant in `k' */ rlm@1: VKNUM, /* nval = numerical value */ rlm@1: VLOCAL, /* info = local register */ rlm@1: VUPVAL, /* info = index of upvalue in `upvalues' */ rlm@1: VGLOBAL, /* info = index of table; aux = index of global name in `k' */ rlm@1: VINDEXED, /* info = table register; aux = index register (or `k') */ rlm@1: VJMP, /* info = instruction pc */ rlm@1: VRELOCABLE, /* info = instruction pc */ rlm@1: VNONRELOC, /* info = result register */ rlm@1: VCALL, /* info = instruction pc */ rlm@1: VVARARG /* info = instruction pc */ rlm@1: } expkind; rlm@1: rlm@1: typedef struct expdesc { rlm@1: expkind k; rlm@1: union { rlm@1: struct { int info, aux; } s; rlm@1: lua_Number nval; rlm@1: } u; rlm@1: int t; /* patch list of `exit when true' */ rlm@1: int f; /* patch list of `exit when false' */ rlm@1: } expdesc; rlm@1: rlm@1: rlm@1: typedef struct upvaldesc { rlm@1: lu_byte k; rlm@1: lu_byte info; rlm@1: } upvaldesc; rlm@1: rlm@1: rlm@1: struct BlockCnt; /* defined in lparser.c */ rlm@1: rlm@1: rlm@1: /* state needed to generate code for a given function */ rlm@1: typedef struct FuncState { rlm@1: Proto *f; /* current function header */ rlm@1: Table *h; /* table to find (and reuse) elements in `k' */ rlm@1: struct FuncState *prev; /* enclosing function */ rlm@1: struct LexState *ls; /* lexical state */ rlm@1: struct lua_State *L; /* copy of the Lua state */ rlm@1: struct BlockCnt *bl; /* chain of current blocks */ rlm@1: int pc; /* next position to code (equivalent to `ncode') */ rlm@1: int lasttarget; /* `pc' of last `jump target' */ rlm@1: int jpc; /* list of pending jumps to `pc' */ rlm@1: int freereg; /* first free register */ rlm@1: int nk; /* number of elements in `k' */ rlm@1: int np; /* number of elements in `p' */ rlm@1: short nlocvars; /* number of elements in `locvars' */ rlm@1: lu_byte nactvar; /* number of active local variables */ rlm@1: upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ rlm@1: unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ rlm@1: } FuncState; rlm@1: rlm@1: rlm@1: LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, rlm@1: const char *name); rlm@1: rlm@1: rlm@1: #endif