aboutsummaryrefslogtreecommitdiff
path: root/llex.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-05-27 10:08:34 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-05-27 10:08:34 -0300
commit7e59a8901d063dbea4eb0693c9c2d85bda1fc5f6 (patch)
tree1834168cd16e821a017e3d8408978f89e6c2ddaf /llex.h
parentabc6eac404da8181ad945ac6950f61a65ba7dfa5 (diff)
downloadlua-7e59a8901d063dbea4eb0693c9c2d85bda1fc5f6.tar.gz
lua-7e59a8901d063dbea4eb0693c9c2d85bda1fc5f6.tar.bz2
lua-7e59a8901d063dbea4eb0693c9c2d85bda1fc5f6.zip
NEW LL(1) PARSER
Diffstat (limited to 'llex.h')
-rw-r--r--llex.h31
1 files changed, 26 insertions, 5 deletions
diff --git a/llex.h b/llex.h
index dcce5149..3947bf5d 100644
--- a/llex.h
+++ b/llex.h
@@ -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
19enum 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
25typedef struct LexState { 39typedef 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
36void luaX_init (void); 54void luaX_init (void);
37void luaX_setinput (ZIO *z); 55void luaX_setinput (LexState *LS, ZIO *z);
38char *luaX_lasttoken (void); 56int luaX_lex (LexState *LS);
57void luaX_syntaxerror (LexState *ls, char *s, char *token);
58void luaX_error (LexState *ls, char *s);
59void luaX_token2str (LexState *ls, int token, char *s);
39 60
40 61
41#endif 62#endif