freebsd: Use compiler.h from FreeBSD's base's linuxkpi
[zfs.git] / module / lua / llex.h
blob43313451539ff0cc54621caec405fe5fb142353d
1 /*
2 ** $Id: llex.h,v 1.72.1.1 2013/04/12 18:48:47 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 257
19 * WARNING: if you change the order of this enumeration,
20 * grep "ORDER RESERVED"
22 enum RESERVED {
23 /* terminal symbols denoted by reserved words */
24 TK_AND = FIRST_RESERVED, TK_BREAK,
25 TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
26 TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
27 TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
28 /* other terminal symbols */
29 TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS,
30 TK_NUMBER, TK_NAME, TK_STRING
33 /* number of reserved words */
34 #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
37 typedef union {
38 lua_Number r;
39 TString *ts;
40 } SemInfo; /* semantics information */
43 typedef struct Token {
44 int token;
45 SemInfo seminfo;
46 } Token;
48 #ifdef current
49 #undef current
50 #endif
52 /* state of the lexer plus state of the parser when shared by all
53 functions */
54 typedef struct LexState {
55 int current; /* current character (charint) */
56 int linenumber; /* input line counter */
57 int lastline; /* line of last token `consumed' */
58 Token t; /* current token */
59 Token lookahead; /* look ahead token */
60 struct FuncState *fs; /* current function (parser) */
61 struct lua_State *L;
62 ZIO *z; /* input stream */
63 Mbuffer *buff; /* buffer for tokens */
64 struct Dyndata *dyd; /* dynamic structures used by the parser */
65 TString *source; /* current source name */
66 TString *envn; /* environment variable name */
67 char decpoint; /* locale decimal point */
68 } LexState;
71 LUAI_FUNC void luaX_init (lua_State *L);
72 LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
73 TString *source, int firstchar);
74 LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
75 LUAI_FUNC void luaX_next (LexState *ls);
76 LUAI_FUNC int luaX_lookahead (LexState *ls);
77 LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s);
78 LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
81 #endif