diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-02-04 15:34:43 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-02-04 15:34:43 -0200 |
| commit | 7cc0e63d8a5bd45eabd328c398f02a933e07746d (patch) | |
| tree | 94a00b4e19c3c1ea0c6e3ee2e3dbb036d960f5c0 /lparser.h | |
| parent | a4a8914c2097bdcaaa4e82c5fd1c9b0c7371e432 (diff) | |
| download | lua-7cc0e63d8a5bd45eabd328c398f02a933e07746d.tar.gz lua-7cc0e63d8a5bd45eabd328c398f02a933e07746d.tar.bz2 lua-7cc0e63d8a5bd45eabd328c398f02a933e07746d.zip | |
first implementation of 'goto'
Diffstat (limited to 'lparser.h')
| -rw-r--r-- | lparser.h | 47 |
1 files changed, 41 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.h,v 1.64 2010/07/02 20:42:40 roberto Exp roberto $ | 2 | ** $Id: lparser.h,v 1.65 2010/07/07 16:27:29 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 | */ |
| @@ -53,19 +53,53 @@ typedef struct expdesc { | |||
| 53 | } expdesc; | 53 | } expdesc; |
| 54 | 54 | ||
| 55 | 55 | ||
| 56 | typedef struct vardesc { | 56 | /* description of active local variable */ |
| 57 | unsigned short idx; | 57 | typedef struct Vardesc { |
| 58 | } vardesc; | 58 | unsigned short idx; /* variable index in stack */ |
| 59 | } Vardesc; | ||
| 59 | 60 | ||
| 60 | 61 | ||
| 61 | /* list of all active local variables */ | 62 | /* list of all active local variables */ |
| 62 | typedef struct Varlist { | 63 | typedef struct Varlist { |
| 63 | vardesc *actvar; | 64 | Vardesc *actvar; |
| 64 | int nactvar; | 65 | int nactvar; |
| 65 | int actvarsize; | 66 | int actvarsize; |
| 66 | } Varlist; | 67 | } Varlist; |
| 67 | 68 | ||
| 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 { | ||
| 89 | TString *name; | ||
| 90 | int pc; /* label position */ | ||
| 91 | lu_byte nactvar; /* variable level where it appears in current block */ | ||
| 92 | } Labeldesc; | ||
| 93 | |||
| 94 | |||
| 95 | /* list of active labels */ | ||
| 96 | typedef struct Labellist { | ||
| 97 | Labeldesc *label; | ||
| 98 | int nlabel; | ||
| 99 | int labelsize; | ||
| 100 | } Labellist; | ||
| 101 | |||
| 102 | |||
| 69 | struct BlockCnt; /* defined in lparser.c */ | 103 | struct BlockCnt; /* defined in lparser.c */ |
| 70 | 104 | ||
| 71 | 105 | ||
| @@ -91,7 +125,8 @@ typedef struct FuncState { | |||
| 91 | 125 | ||
| 92 | 126 | ||
| 93 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, | 127 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, |
| 94 | Varlist *varl, const char *name); | 128 | Varlist *varl, Gotolist *gtl, |
| 129 | Labellist *labell, const char *name); | ||
| 95 | 130 | ||
| 96 | 131 | ||
| 97 | #endif | 132 | #endif |
