- Main Page
- Related Pages
- Modules
- Data Structures
- Files

# lua/lparser.h

Go to the documentation of this file.

    00001 /*
    00002 ** $Id: lparser.h,v 1.57 2006/03/09 18:14:31 roberto Exp $
    00003 ** Lua Parser
    00004 ** See Copyright Notice in lua.h
    00005 */
    00006
    00007 #ifndef lparser_h
    00008 #define lparser_h
    00009
    00010 #include "llimits.h"
    00011 #include "lobject.h"
    00012 #include "lzio.h"
    00013
    00014
    00015 /*
    00016 ** Expression descriptor
    00017 */
    00018
    00019 typedef enum {
    00020   VVOID,        /* no value */
    00021   VNIL,
    00022   VTRUE,
    00023   VFALSE,
    00024   VK,           /* info = index of constant in `k' */
    00025   VKNUM,        /* nval = numerical value */
    00026   VLOCAL,       /* info = local register */
    00027   VUPVAL,       /* info = index of upvalue in `upvalues' */
    00028   VGLOBAL,      /* info = index of table; aux = index of global name in `k' */
    00029   VINDEXED,     /* info = table register; aux = index register (or `k') */
    00030   VJMP,         /* info = instruction pc */
    00031   VRELOCABLE,   /* info = instruction pc */
    00032   VNONRELOC,    /* info = result register */
    00033   VCALL,        /* info = instruction pc */
    00034   VVARARG       /* info = instruction pc */
    00035 } expkind;
    00036
    00037 typedef struct expdesc {
    00038   expkind k;
    00039   union {
    00040     struct { int info, aux; } s;
    00041     lua_Number nval;
    00042   } u;
    00043   int t;  /* patch list of `exit when true' */
    00044   int f;  /* patch list of `exit when false' */
    00045 } expdesc;
    00046
    00047
    00048 typedef struct upvaldesc {
    00049   lu_byte k;
    00050   lu_byte info;
    00051 } upvaldesc;
    00052
    00053
    00054 struct BlockCnt;  /* defined in lparser.c */
    00055
    00056
    00057 /* state needed to generate code for a given function */
    00058 typedef struct FuncState {
    00059   Proto *f;  /* current function header */
    00060   Table *h;  /* table to find (and reuse) elements in `k' */
    00061   struct FuncState *prev;  /* enclosing function */
    00062   struct LexState *ls;  /* lexical state */
    00063   struct lua_State *L;  /* copy of the Lua state */
    00064   struct BlockCnt *bl;  /* chain of current blocks */
    00065   int pc;  /* next position to code (equivalent to `ncode') */
    00066   int lasttarget;   /* `pc' of last `jump target' */
    00067   int jpc;  /* list of pending jumps to `pc' */
    00068   int freereg;  /* first free register */
    00069   int nk;  /* number of elements in `k' */
    00070   int np;  /* number of elements in `p' */
    00071   short nlocvars;  /* number of elements in `locvars' */
    00072   lu_byte nactvar;  /* number of active local variables */
    00073   upvaldesc upvalues[LUAI_MAXUPVALUES];  /* upvalues */
    00074   unsigned short actvar[LUAI_MAXVARS];  /* declared-variable stack */
    00075 } FuncState;
    00076
    00077
    00078 LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
    00079                                             const char *name);
    00080
    00081
    00082 #endif