diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-05-27 10:08:34 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-05-27 10:08:34 -0300 |
commit | 7e59a8901d063dbea4eb0693c9c2d85bda1fc5f6 (patch) | |
tree | 1834168cd16e821a017e3d8408978f89e6c2ddaf /llex.h | |
parent | abc6eac404da8181ad945ac6950f61a65ba7dfa5 (diff) | |
download | lua-7e59a8901d063dbea4eb0693c9c2d85bda1fc5f6.tar.gz lua-7e59a8901d063dbea4eb0693c9c2d85bda1fc5f6.tar.bz2 lua-7e59a8901d063dbea4eb0693c9c2d85bda1fc5f6.zip |
NEW LL(1) PARSER
Diffstat (limited to 'llex.h')
-rw-r--r-- | llex.h | 31 |
1 files changed, 26 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.h,v 1.6 1997/12/17 20:48:58 roberto Exp roberto $ | 2 | ** $Id: llex.h,v 1.7 1998/01/09 14:57:43 roberto Exp $ |
3 | ** Lexical Analizer | 3 | ** Lexical Analizer |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -11,6 +11,20 @@ | |||
11 | #include "lzio.h" | 11 | #include "lzio.h" |
12 | 12 | ||
13 | 13 | ||
14 | #define FIRST_RESERVED 260 | ||
15 | |||
16 | /* maximum length of a reserved word (+1 for terminal 0) */ | ||
17 | #define TOKEN_LEN 15 | ||
18 | |||
19 | enum RESERVED { | ||
20 | /* terminal symbols denoted by reserved words */ | ||
21 | AND = FIRST_RESERVED, | ||
22 | DO, ELSE, ELSEIF, END, FUNCTION, IF, LOCAL, NIL, NOT, OR, | ||
23 | REPEAT, RETURN, THEN, UNTIL, WHILE, | ||
24 | /* other terminal symbols */ | ||
25 | NAME, CONC, DOTS, EQ, GE, LE, NE, NUMBER, STRING, EOS}; | ||
26 | |||
27 | |||
14 | #define MAX_IFS 5 | 28 | #define MAX_IFS 5 |
15 | 29 | ||
16 | /* "ifstate" keeps the state of each nested $if the lexical is dealing with. */ | 30 | /* "ifstate" keeps the state of each nested $if the lexical is dealing with. */ |
@@ -24,18 +38,25 @@ struct ifState { | |||
24 | 38 | ||
25 | typedef struct LexState { | 39 | typedef struct LexState { |
26 | int current; /* look ahead character */ | 40 | int current; /* look ahead character */ |
41 | int token; /* look ahead token */ | ||
42 | struct FuncState *fs; /* 'FuncState' is private for the parser */ | ||
43 | union { | ||
44 | real r; | ||
45 | TaggedString *ts; | ||
46 | } seminfo; /* semantics information */ | ||
27 | struct zio *lex_z; /* input stream */ | 47 | struct zio *lex_z; /* input stream */ |
28 | int linenumber; /* input line counter */ | 48 | int linenumber; /* input line counter */ |
29 | int linelasttoken; /* line where last token was read */ | ||
30 | int lastline; /* last line wherein a SETLINE was generated */ | ||
31 | int iflevel; /* level of nested $if's (for lexical analysis) */ | 49 | int iflevel; /* level of nested $if's (for lexical analysis) */ |
32 | struct ifState ifstate[MAX_IFS]; | 50 | struct ifState ifstate[MAX_IFS]; |
33 | } LexState; | 51 | } LexState; |
34 | 52 | ||
35 | 53 | ||
36 | void luaX_init (void); | 54 | void luaX_init (void); |
37 | void luaX_setinput (ZIO *z); | 55 | void luaX_setinput (LexState *LS, ZIO *z); |
38 | char *luaX_lasttoken (void); | 56 | int luaX_lex (LexState *LS); |
57 | void luaX_syntaxerror (LexState *ls, char *s, char *token); | ||
58 | void luaX_error (LexState *ls, char *s); | ||
59 | void luaX_token2str (LexState *ls, int token, char *s); | ||
39 | 60 | ||
40 | 61 | ||
41 | #endif | 62 | #endif |