Imported from ../lua-5.0.3.tar.gz.
[lua.git] / src / lparser.h
blobd6aaaf0e7d37f7201ac711830db5be6d2de10c48
1 /*
2 ** $Id: lparser.h,v 1.47 2003/02/11 10:46:24 roberto Exp $
3 ** Lua Parser
4 ** See Copyright Notice in lua.h
5 */
7 #ifndef lparser_h
8 #define lparser_h
10 #include "llimits.h"
11 #include "lobject.h"
12 #include "ltable.h"
13 #include "lzio.h"
17 ** Expression descriptor
20 typedef enum {
21 VVOID, /* no value */
22 VNIL,
23 VTRUE,
24 VFALSE,
25 VK, /* info = index of constant in `k' */
26 VLOCAL, /* info = local register */
27 VUPVAL, /* info = index of upvalue in `upvalues' */
28 VGLOBAL, /* info = index of table; aux = index of global name in `k' */
29 VINDEXED, /* info = table register; aux = index register (or `k') */
30 VJMP, /* info = instruction pc */
31 VRELOCABLE, /* info = instruction pc */
32 VNONRELOC, /* info = result register */
33 VCALL /* info = result register */
34 } expkind;
36 typedef struct expdesc {
37 expkind k;
38 int info, aux;
39 int t; /* patch list of `exit when true' */
40 int f; /* patch list of `exit when false' */
41 } expdesc;
44 struct BlockCnt; /* defined in lparser.c */
47 /* state needed to generate code for a given function */
48 typedef struct FuncState {
49 Proto *f; /* current function header */
50 Table *h; /* table to find (and reuse) elements in `k' */
51 struct FuncState *prev; /* enclosing function */
52 struct LexState *ls; /* lexical state */
53 struct lua_State *L; /* copy of the Lua state */
54 struct BlockCnt *bl; /* chain of current blocks */
55 int pc; /* next position to code (equivalent to `ncode') */
56 int lasttarget; /* `pc' of last `jump target' */
57 int jpc; /* list of pending jumps to `pc' */
58 int freereg; /* first free register */
59 int nk; /* number of elements in `k' */
60 int np; /* number of elements in `p' */
61 int nlocvars; /* number of elements in `locvars' */
62 int nactvar; /* number of active local variables */
63 expdesc upvalues[MAXUPVALUES]; /* upvalues */
64 int actvar[MAXVARS]; /* declared-variable stack */
65 } FuncState;
68 Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff);
71 #endif