annotate lib/lua/lua-5.2.2/lparser.h @ 2553:48708da03b7f

Party Creation UI logic separated from MainMenu
author a.parshin
date Wed, 13 May 2015 02:20:05 +0200
parents 41cc4dd3c122
children
rev   line source
1866
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
1 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
2 ** $Id: lparser.h,v 1.70 2012/05/08 13:53:33 roberto Exp $
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
3 ** Lua Parser
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
4 ** See Copyright Notice in lua.h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
5 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
6
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
7 #ifndef lparser_h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
8 #define lparser_h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
9
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
10 #include "llimits.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
11 #include "lobject.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
12 #include "lzio.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
13
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
14
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
15 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
16 ** Expression descriptor
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
17 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
18
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
19 typedef enum {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
20 VVOID, /* no value */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
21 VNIL,
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
22 VTRUE,
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
23 VFALSE,
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
24 VK, /* info = index of constant in `k' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
25 VKNUM, /* nval = numerical value */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
26 VNONRELOC, /* info = result register */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
27 VLOCAL, /* info = local register */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
28 VUPVAL, /* info = index of upvalue in 'upvalues' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
29 VINDEXED, /* t = table register/upvalue; idx = index R/K */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
30 VJMP, /* info = instruction pc */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
31 VRELOCABLE, /* info = instruction pc */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
32 VCALL, /* info = instruction pc */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
33 VVARARG /* info = instruction pc */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
34 } expkind;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
35
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
36
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
37 #define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
38 #define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
39
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
40 typedef struct expdesc {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
41 expkind k;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
42 union {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
43 struct { /* for indexed variables (VINDEXED) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
44 short idx; /* index (R/K) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
45 lu_byte t; /* table (register or upvalue) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
46 lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
47 } ind;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
48 int info; /* for generic use */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
49 lua_Number nval; /* for VKNUM */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
50 } u;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
51 int t; /* patch list of `exit when true' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
52 int f; /* patch list of `exit when false' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
53 } expdesc;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
54
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
55
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
56 /* description of active local variable */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
57 typedef struct Vardesc {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
58 short idx; /* variable index in stack */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
59 } Vardesc;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
60
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
61
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
62 /* description of pending goto statements and label statements */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
63 typedef struct Labeldesc {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
64 TString *name; /* label identifier */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
65 int pc; /* position in code */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
66 int line; /* line where it appeared */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
67 lu_byte nactvar; /* local level where it appears in current block */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
68 } Labeldesc;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
69
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
70
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
71 /* list of labels or gotos */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
72 typedef struct Labellist {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
73 Labeldesc *arr; /* array */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
74 int n; /* number of entries in use */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
75 int size; /* array size */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
76 } Labellist;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
77
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
78
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
79 /* dynamic structures used by the parser */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
80 typedef struct Dyndata {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
81 struct { /* list of active local variables */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
82 Vardesc *arr;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
83 int n;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
84 int size;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
85 } actvar;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
86 Labellist gt; /* list of pending gotos */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
87 Labellist label; /* list of active labels */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
88 } Dyndata;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
89
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
90
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
91 /* control of blocks */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
92 struct BlockCnt; /* defined in lparser.c */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
93
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
94
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
95 /* state needed to generate code for a given function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
96 typedef struct FuncState {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
97 Proto *f; /* current function header */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
98 Table *h; /* table to find (and reuse) elements in `k' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
99 struct FuncState *prev; /* enclosing function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
100 struct LexState *ls; /* lexical state */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
101 struct BlockCnt *bl; /* chain of current blocks */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
102 int pc; /* next position to code (equivalent to `ncode') */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
103 int lasttarget; /* 'label' of last 'jump label' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
104 int jpc; /* list of pending jumps to `pc' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
105 int nk; /* number of elements in `k' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
106 int np; /* number of elements in `p' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
107 int firstlocal; /* index of first local var (in Dyndata array) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
108 short nlocvars; /* number of elements in 'f->locvars' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
109 lu_byte nactvar; /* number of active local variables */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
110 lu_byte nups; /* number of upvalues */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
111 lu_byte freereg; /* first free register */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
112 } FuncState;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
113
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
114
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
115 LUAI_FUNC Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
116 Dyndata *dyd, const char *name, int firstchar);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
117
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
118
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
119 #endif