Imported from ../lua-3.2.tar.gz.
[lua.git] / src / llex.h
blob7c1a4be1f8133813cc4ef9a3e95729d8ac131b7e
1 /*
2 ** $Id: llex.h,v 1.12 1999/06/17 17:04:03 roberto Exp $
3 ** Lexical Analyzer
4 ** See Copyright Notice in lua.h
5 */
7 #ifndef llex_h
8 #define llex_h
10 #include "lobject.h"
11 #include "lzio.h"
14 #define FIRST_RESERVED 260
16 /* maximum length of a reserved word (+1 for terminal 0) */
17 #define TOKEN_LEN 15
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};
28 #ifndef MAX_IFS
29 #define MAX_IFS 5 /* arbitrary limit */
30 #endif
32 /* "ifstate" keeps the state of each nested $if the lexical is dealing with. */
34 struct ifState {
35 int elsepart; /* true if it's in the $else part */
36 int condition; /* true if $if condition is true */
37 int skip; /* true if part must be skipped */
41 typedef struct LexState {
42 int current; /* look ahead character */
43 int token; /* look ahead token */
44 struct FuncState *fs; /* 'FuncState' is private for the parser */
45 union {
46 real r;
47 TaggedString *ts;
48 } seminfo; /* semantics information */
49 struct zio *lex_z; /* input stream */
50 int linenumber; /* input line counter */
51 int iflevel; /* level of nested $if's (for lexical analysis) */
52 struct ifState ifstate[MAX_IFS];
53 } LexState;
56 void luaX_init (void);
57 void luaX_setinput (LexState *LS, ZIO *z);
58 int luaX_lex (LexState *LS);
59 void luaX_syntaxerror (LexState *ls, char *s, char *token);
60 void luaX_error (LexState *ls, char *s);
61 void luaX_token2str (int token, char *s);
64 #endif