llex.h
Go to the documentation of this file.
1 /*
2 ** $Id: llex.h $
3 ** Lexical Analyzer
4 ** See Copyright Notice in lua.h
5 */
6 
7 #ifndef llex_h
8 #define llex_h
9 
10 #include <limits.h>
11 
12 #include "lobject.h"
13 #include "lzio.h"
14 
15 
16 /*
17 ** Single-char tokens (terminal symbols) are represented by their own
18 ** numeric code. Other tokens start at the following value.
19 */
20 #define FIRST_RESERVED (UCHAR_MAX + 1)
21 
22 
23 #if !defined(LUA_ENV)
24 #define LUA_ENV "_ENV"
25 #endif
26 
27 
28 /*
29 * WARNING: if you change the order of this enumeration,
30 * grep "ORDER RESERVED"
31 */
32 enum RESERVED {
33  /* terminal symbols denoted by reserved words */
38  /* other terminal symbols */
43 };
44 
45 /* number of reserved words */
46 #define NUM_RESERVED (cast_int(TK_WHILE-FIRST_RESERVED + 1))
47 
48 
49 typedef union {
53 } SemInfo; /* semantics information */
54 
55 
56 typedef struct Token {
57  int token;
59 } Token;
60 
61 
62 /* state of the lexer plus state of the parser when shared by all
63  functions */
64 typedef struct LexState {
65  int current; /* current character (charint) */
66  int linenumber; /* input line counter */
67  int lastline; /* line of last token 'consumed' */
68  Token t; /* current token */
69  Token lookahead; /* look ahead token */
70  struct FuncState *fs; /* current function (parser) */
71  struct lua_State *L;
72  ZIO *z; /* input stream */
73  Mbuffer *buff; /* buffer for tokens */
74  Table *h; /* to avoid collection/reuse strings */
75  struct Dyndata *dyd; /* dynamic structures used by the parser */
76  TString *source; /* current source name */
77  TString *envn; /* environment variable name */
78 } LexState;
79 
80 
81 LUAI_FUNC void luaX_init (lua_State *L);
82 LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
83  TString *source, int firstchar);
84 LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
85 LUAI_FUNC void luaX_next (LexState *ls);
87 LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s);
88 LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
89 
90 
91 #endif
struct Dyndata * dyd
Definition: llex.h:75
Definition: llex.h:37
Definition: llex.h:35
Definition: llex.h:36
TString * envn
Definition: llex.h:77
Definition: llex.h:34
Definition: lobject.h:712
Definition: llex.h:42
LUAI_FUNC void luaX_setinput(lua_State *L, LexState *ls, ZIO *z, TString *source, int firstchar)
Definition: llex.c:164
Definition: llex.h:40
Definition: llex.h:35
#define LUAI_FUNC
Definition: luaconf.h:322
Definition: llex.h:49
LUAI_FUNC void luaX_next(LexState *ls)
Definition: llex.c:561
Definition: llex.h:36
TString * ts
Definition: llex.h:52
int linenumber
Definition: llex.h:66
LUAI_FUNC void luaX_init(lua_State *L)
Definition: llex.c:70
int current
Definition: llex.h:65
int token
Definition: llex.h:57
struct Token Token
RESERVED
Definition: llex.h:32
Token lookahead
Definition: llex.h:69
Definition: llex.h:37
#define l_noret
Definition: llimits.h:178
Definition: llex.h:39
Definition: llex.h:39
Definition: llex.h:35
Token t
Definition: llex.h:68
Definition: llex.h:41
Definition: llex.h:56
Definition: llex.h:37
Definition: llex.h:36
Definition: llex.h:39
LUA_INTEGER lua_Integer
Definition: lua.h:94
SemInfo seminfo
Definition: llex.h:58
Definition: llex.h:39
Definition: llex.h:42
Definition: llex.h:35
Definition: llex.h:37
LUAI_FUNC const char * luaX_token2str(LexState *ls, int token)
Definition: llex.c:82
Definition: llex.h:36
struct FuncState * fs
Definition: llex.h:70
Definition: llex.h:39
Definition: llex.h:34
Definition: lzio.h:55
Definition: llex.h:37
Definition: llex.h:35
TString * source
Definition: llex.h:76
Definition: llex.h:35
Definition: llex.h:64
lua_Number r
Definition: llex.h:50
Definition: llex.h:36
Definition: llex.h:36
LUAI_FUNC TString * luaX_newstring(LexState *ls, const char *str, size_t l)
Definition: llex.c:129
LUAI_FUNC l_noret luaX_syntaxerror(LexState *ls, const char *s)
Definition: llex.c:119
Definition: llex.h:39
#define FIRST_RESERVED
Definition: llex.h:20
struct lua_State * L
Definition: llex.h:71
Table * h
Definition: llex.h:74
Definition: llex.h:36
Definition: llex.h:36
Definition: lzio.h:23
Definition: llex.h:42
LUAI_FUNC int luaX_lookahead(LexState *ls)
Definition: llex.c:572
Definition: llex.h:40
lua_Integer i
Definition: llex.h:51
struct LexState LexState
Definition: llex.h:39
Mbuffer * buff
Definition: llex.h:73
LUA_NUMBER lua_Number
Definition: lua.h:90
Definition: llex.h:42
ZIO * z
Definition: llex.h:72
int lastline
Definition: llex.h:67


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:09