/*1** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $2** Lua Parser3** See Copyright Notice in lua.h4*/56#ifndef lparser_h7#define lparser_h89#include "llimits.h"10#include "lobject.h"11#include "lzio.h"121314/*15** Expression descriptor16*/1718typedef enum {19VVOID, /* no value */20VNIL,21VTRUE,22VFALSE,23VK, /* info = index of constant in `k' */24VKNUM, /* nval = numerical value */25VLOCAL, /* info = local register */26VUPVAL, /* info = index of upvalue in `upvalues' */27VGLOBAL, /* info = index of table; aux = index of global name in `k' */28VINDEXED, /* info = table register; aux = index register (or `k') */29VJMP, /* info = instruction pc */30VRELOCABLE, /* info = instruction pc */31VNONRELOC, /* info = result register */32VCALL, /* info = instruction pc */33VVARARG /* info = instruction pc */34} expkind;3536typedef struct expdesc {37expkind k;38union {39struct { int info, aux; } s;40lua_Number nval;41} u;42int t; /* patch list of `exit when true' */43int f; /* patch list of `exit when false' */44} expdesc;454647typedef struct upvaldesc {48lu_byte k;49lu_byte info;50} upvaldesc;515253struct BlockCnt; /* defined in lparser.c */545556/* state needed to generate code for a given function */57typedef struct FuncState {58Proto *f; /* current function header */59Table *h; /* table to find (and reuse) elements in `k' */60struct FuncState *prev; /* enclosing function */61struct LexState *ls; /* lexical state */62struct lua_State *L; /* copy of the Lua state */63struct BlockCnt *bl; /* chain of current blocks */64int pc; /* next position to code (equivalent to `ncode') */65int lasttarget; /* `pc' of last `jump target' */66int jpc; /* list of pending jumps to `pc' */67int freereg; /* first free register */68int nk; /* number of elements in `k' */69int np; /* number of elements in `p' */70short nlocvars; /* number of elements in `locvars' */71lu_byte nactvar; /* number of active local variables */72upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */73unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */74} FuncState;757677LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,78const char *name);798081#endif828384