rpm  4.5
llex.h
Go to the documentation of this file.
1 /*
2 ** $Id: llex.h,v 1.1 2004/03/16 21:58:30 niemeyer Exp $
3 ** Lexical Analyzer
4 ** See Copyright Notice in lua.h
5 */
6 
7 #ifndef llex_h
8 #define llex_h
9 
10 #include "lobject.h"
11 #include "lzio.h"
12 
13 
14 #define FIRST_RESERVED 257
15 
16 /* maximum length of a reserved word */
17 #define TOKEN_LEN (sizeof("function")/sizeof(char))
18 
19 
20 /*
21 * WARNING: if you change the order of this enumeration,
22 * grep "ORDER RESERVED"
23 */
24 enum RESERVED {
25  /* terminal symbols denoted by reserved words */
30  /* other terminal symbols */
33 };
34 
35 /* number of reserved words */
36 #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
37 
38 
39 typedef union {
40  lua_Number r;
41 /*@null@*/
43 } SemInfo; /* semantics information */
44 
45 
46 typedef struct Token {
47  int token;
49 } Token;
50 
51 
52 typedef struct LexState {
53  int current; /* current character (charint) */
54  int linenumber; /* input line counter */
55  int lastline; /* line of last token `consumed' */
56  Token t; /* current token */
57  Token lookahead; /* look ahead token */
58  struct FuncState *fs; /* `FuncState' is private to the parser */
59  struct lua_State *L;
60  ZIO *z; /* input stream */
61  Mbuffer *buff; /* buffer for tokens */
62  TString *source; /* current source name */
63  int nestlevel; /* level of nested non-terminals */
64 } LexState;
65 
66 
67 void luaX_init (lua_State *L)
68  /*@modifies L @*/;
69 void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source)
70  /*@modifies LS, z @*/;
71 int luaX_lex (LexState *LS, SemInfo *seminfo)
72  /*@modifies LS, seminfo @*/;
73 void luaX_checklimit (LexState *ls, int val, int limit, const char *msg)
74  /*@modifies ls @*/;
75 void luaX_syntaxerror (LexState *ls, const char *s)
76  /*@modifies ls @*/;
77 void luaX_errorline (LexState *ls, const char *s, const char *token, int line)
78  /*@modifies ls @*/;
79 /*@observer@*/
80 const char *luaX_token2str (LexState *ls, int token)
81  /*@modifies ls @*/;
82 
83 
84 #endif