diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-02-07 15:14:50 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-02-07 15:14:50 -0200 |
commit | f0797492875dec5bf7a23b9172809bc92c0c04cd (patch) | |
tree | 712c44cd08fc8ee3a12c11029dc50f1988f8628f /lparser.h | |
parent | f8d677f94c3b4309be94698d33aeb0590a51eabc (diff) | |
download | lua-f0797492875dec5bf7a23b9172809bc92c0c04cd.tar.gz lua-f0797492875dec5bf7a23b9172809bc92c0c04cd.tar.bz2 lua-f0797492875dec5bf7a23b9172809bc92c0c04cd.zip |
some reorganization of dynamic data structures used by the parser
Diffstat (limited to 'lparser.h')
-rw-r--r-- | lparser.h | 60 |
1 files changed, 24 insertions, 36 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.h,v 1.65 2010/07/07 16:27:29 roberto Exp roberto $ | 2 | ** $Id: lparser.h,v 1.66 2011/02/04 17:34:43 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -59,47 +59,36 @@ typedef struct Vardesc { | |||
59 | } Vardesc; | 59 | } Vardesc; |
60 | 60 | ||
61 | 61 | ||
62 | /* list of all active local variables */ | 62 | /* description of pending goto statements and label statements */ |
63 | typedef struct Varlist { | ||
64 | Vardesc *actvar; | ||
65 | int nactvar; | ||
66 | int actvarsize; | ||
67 | } Varlist; | ||
68 | |||
69 | |||
70 | /* description of pending goto statement */ | ||
71 | typedef struct Gotodesc { | ||
72 | TString *name; | ||
73 | int pc; /* where it is coded */ | ||
74 | int line; /* line where it appeared */ | ||
75 | lu_byte currlevel; /* variable level where it appears in current block */ | ||
76 | } Gotodesc; | ||
77 | |||
78 | |||
79 | /* list of pending gotos */ | ||
80 | typedef struct Gotolist { | ||
81 | Gotodesc *gt; | ||
82 | int ngt; | ||
83 | int gtsize; | ||
84 | } Gotolist; | ||
85 | |||
86 | |||
87 | /* description of active labels */ | ||
88 | typedef struct Labeldesc { | 63 | typedef struct Labeldesc { |
89 | TString *name; | 64 | TString *name; /* label identifier */ |
90 | int pc; /* label position */ | 65 | int pc; /* position in code */ |
91 | lu_byte nactvar; /* variable level where it appears in current block */ | 66 | int line; /* line where it appeared */ |
67 | lu_byte nactvar; /* local level where it appears in current block */ | ||
92 | } Labeldesc; | 68 | } Labeldesc; |
93 | 69 | ||
94 | 70 | ||
95 | /* list of active labels */ | 71 | /* list of labels or gotos */ |
96 | typedef struct Labellist { | 72 | typedef struct Labellist { |
97 | Labeldesc *label; | 73 | Labeldesc *arr; /* array */ |
98 | int nlabel; | 74 | int n; /* number of entries in use */ |
99 | int labelsize; | 75 | int size; /* array size */ |
100 | } Labellist; | 76 | } Labellist; |
101 | 77 | ||
102 | 78 | ||
79 | /* dynamic structures used by the parser */ | ||
80 | typedef struct Dyndata { | ||
81 | struct { /* list of active local variables */ | ||
82 | Vardesc *arr; | ||
83 | int n; | ||
84 | int size; | ||
85 | } actvar; | ||
86 | Labellist gt; /* list of pending gotos */ | ||
87 | Labellist label; /* list of active labels */ | ||
88 | } Dyndata; | ||
89 | |||
90 | |||
91 | /* control of blocks */ | ||
103 | struct BlockCnt; /* defined in lparser.c */ | 92 | struct BlockCnt; /* defined in lparser.c */ |
104 | 93 | ||
105 | 94 | ||
@@ -125,8 +114,7 @@ typedef struct FuncState { | |||
125 | 114 | ||
126 | 115 | ||
127 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, | 116 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, |
128 | Varlist *varl, Gotolist *gtl, | 117 | Dyndata *dyd, const char *name); |
129 | Labellist *labell, const char *name); | ||
130 | 118 | ||
131 | 119 | ||
132 | #endif | 120 | #endif |