diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-03 09:33:59 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-03 09:33:59 -0300 |
commit | f7840a3e0bc07813246b2bad6bf4579848187908 (patch) | |
tree | 8fe680329b87a8f5ba2ffeb920f8bbeb300e64b8 /lparser.h | |
parent | 1780e2c977da2eadd71a982b9db1db1d768ebd8a (diff) | |
download | lua-f7840a3e0bc07813246b2bad6bf4579848187908.tar.gz lua-f7840a3e0bc07813246b2bad6bf4579848187908.tar.bz2 lua-f7840a3e0bc07813246b2bad6bf4579848187908.zip |
new algorithm to parse expressions + distribution of code between lparser
and lcode.
Diffstat (limited to 'lparser.h')
-rw-r--r-- | lparser.h | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.h,v 1.5 1999/11/22 13:12:07 roberto Exp roberto $ | 2 | ** $Id: lparser.h,v 1.6 2000/02/22 13:30:11 roberto Exp roberto $ |
3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -50,21 +50,19 @@ | |||
50 | 50 | ||
51 | 51 | ||
52 | /* | 52 | /* |
53 | ** Variable descriptor: | 53 | ** Expression descriptor |
54 | ** must include an `exp' option because LL(1) cannot distinguish | ||
55 | ** between variables, upvalues and function calls on first sight. | ||
56 | */ | 54 | */ |
57 | typedef enum { | 55 | typedef enum { |
58 | VGLOBAL, /* info is constant index of global name */ | 56 | VGLOBAL, /* info is constant index of global name */ |
59 | VLOCAL, /* info is stack index */ | 57 | VLOCAL, /* info is stack index */ |
60 | VINDEXED, /* no info (table and index are on the stack) */ | 58 | VINDEXED, /* no info (table and index are on the stack) */ |
61 | VEXP /* info is pc index of a call (or 0 if exp is closed) */ | 59 | VEXP /* info is pc index of exp main operator */ |
62 | } varkind; | 60 | } expkind; |
63 | 61 | ||
64 | typedef struct vardesc { | 62 | typedef struct expdesc { |
65 | varkind k; | 63 | expkind k; |
66 | int info; | 64 | int info; |
67 | } vardesc; | 65 | } expdesc; |
68 | 66 | ||
69 | 67 | ||
70 | /* state needed to generate code for a given function */ | 68 | /* state needed to generate code for a given function */ |
@@ -78,7 +76,7 @@ typedef struct FuncState { | |||
78 | int nupvalues; /* number of upvalues */ | 76 | int nupvalues; /* number of upvalues */ |
79 | int nvars; /* number of entries in f->locvars (-1 if no debug information) */ | 77 | int nvars; /* number of entries in f->locvars (-1 if no debug information) */ |
80 | int lastsetline; /* line where last SETLINE was issued */ | 78 | int lastsetline; /* line where last SETLINE was issued */ |
81 | vardesc upvalues[MAXUPVALUES]; /* upvalues */ | 79 | expdesc upvalues[MAXUPVALUES]; /* upvalues */ |
82 | TaggedString *localvar[MAXLOCALS]; /* store local variable names */ | 80 | TaggedString *localvar[MAXLOCALS]; /* store local variable names */ |
83 | } FuncState; | 81 | } FuncState; |
84 | 82 | ||