Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
3rdparty
lua-5.4.1
src
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 */
34
TK_AND
=
FIRST_RESERVED
,
TK_BREAK
,
35
TK_DO
,
TK_ELSE
,
TK_ELSEIF
,
TK_END
,
TK_FALSE
,
TK_FOR
,
TK_FUNCTION
,
36
TK_GOTO
,
TK_IF
,
TK_IN
,
TK_LOCAL
,
TK_NIL
,
TK_NOT
,
TK_OR
,
TK_REPEAT
,
37
TK_RETURN
,
TK_THEN
,
TK_TRUE
,
TK_UNTIL
,
TK_WHILE
,
38
/* other terminal symbols */
39
TK_IDIV
,
TK_CONCAT
,
TK_DOTS
,
TK_EQ
,
TK_GE
,
TK_LE
,
TK_NE
,
40
TK_SHL
,
TK_SHR
,
41
TK_DBCOLON
,
TK_EOS
,
42
TK_FLT
,
TK_INT
,
TK_NAME
,
TK_STRING
43
};
44
45
/* number of reserved words */
46
#define NUM_RESERVED (cast_int(TK_WHILE-FIRST_RESERVED + 1))
47
48
49
typedef
union
{
50
lua_Number
r
;
51
lua_Integer
i
;
52
TString
*
ts
;
53
}
SemInfo
;
/* semantics information */
54
55
56
typedef
struct
Token
{
57
int
token
;
58
SemInfo
seminfo
;
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);
86
LUAI_FUNC
int
luaX_lookahead
(
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
LexState::dyd
struct Dyndata * dyd
Definition:
llex.h:75
TK_TRUE
Definition:
llex.h:37
TK_ELSE
Definition:
llex.h:35
TK_NIL
Definition:
llex.h:36
LexState::envn
TString * envn
Definition:
llex.h:77
TK_BREAK
Definition:
llex.h:34
Table
Definition:
lobject.h:712
TK_NAME
Definition:
llex.h:42
luaX_setinput
LUAI_FUNC void luaX_setinput(lua_State *L, LexState *ls, ZIO *z, TString *source, int firstchar)
Definition:
llex.c:164
TK_SHL
Definition:
llex.h:40
TK_END
Definition:
llex.h:35
LUAI_FUNC
#define LUAI_FUNC
Definition:
luaconf.h:322
SemInfo
Definition:
llex.h:49
Dyndata
Definition:
lparser.h:127
luaX_next
LUAI_FUNC void luaX_next(LexState *ls)
Definition:
llex.c:561
TK_IF
Definition:
llex.h:36
SemInfo::ts
TString * ts
Definition:
llex.h:52
FuncState
Definition:
lparser.h:143
LexState::linenumber
int linenumber
Definition:
llex.h:66
luaX_init
LUAI_FUNC void luaX_init(lua_State *L)
Definition:
llex.c:70
LexState::current
int current
Definition:
llex.h:65
Token::token
int token
Definition:
llex.h:57
Token
struct Token Token
RESERVED
RESERVED
Definition:
llex.h:32
LexState::lookahead
Token lookahead
Definition:
llex.h:69
TK_THEN
Definition:
llex.h:37
l_noret
#define l_noret
Definition:
llimits.h:178
TK_LE
Definition:
llex.h:39
TK_NE
Definition:
llex.h:39
TK_ELSEIF
Definition:
llex.h:35
LexState::t
Token t
Definition:
llex.h:68
TK_EOS
Definition:
llex.h:41
Token
Definition:
llex.h:56
TK_WHILE
Definition:
llex.h:37
TK_OR
Definition:
llex.h:36
TK_GE
Definition:
llex.h:39
lua_Integer
LUA_INTEGER lua_Integer
Definition:
lua.h:94
lobject.h
Token::seminfo
SemInfo seminfo
Definition:
llex.h:58
TK_IDIV
Definition:
llex.h:39
TK_INT
Definition:
llex.h:42
TK_FOR
Definition:
llex.h:35
lua_State
Definition:
lstate.h:306
TK_RETURN
Definition:
llex.h:37
luaX_token2str
LUAI_FUNC const char * luaX_token2str(LexState *ls, int token)
Definition:
llex.c:82
TK_LOCAL
Definition:
llex.h:36
LexState::fs
struct FuncState * fs
Definition:
llex.h:70
lzio.h
TK_DOTS
Definition:
llex.h:39
TK_DBCOLON
Definition:
llex.h:41
TK_AND
Definition:
llex.h:34
Zio
Definition:
lzio.h:55
TK_UNTIL
Definition:
llex.h:37
TK_FALSE
Definition:
llex.h:35
LexState::source
TString * source
Definition:
llex.h:76
TK_DO
Definition:
llex.h:35
LexState
Definition:
llex.h:64
TK_FUNCTION
Definition:
llex.h:35
SemInfo::r
lua_Number r
Definition:
llex.h:50
TK_NOT
Definition:
llex.h:36
TK_IN
Definition:
llex.h:36
luaX_newstring
LUAI_FUNC TString * luaX_newstring(LexState *ls, const char *str, size_t l)
Definition:
llex.c:129
luaX_syntaxerror
LUAI_FUNC l_noret luaX_syntaxerror(LexState *ls, const char *s)
Definition:
llex.c:119
TK_EQ
Definition:
llex.h:39
FIRST_RESERVED
#define FIRST_RESERVED
Definition:
llex.h:20
TString
Definition:
lobject.h:362
LexState::L
struct lua_State * L
Definition:
llex.h:71
LexState::h
Table * h
Definition:
llex.h:74
TK_REPEAT
Definition:
llex.h:36
TK_GOTO
Definition:
llex.h:36
Mbuffer
Definition:
lzio.h:23
TK_FLT
Definition:
llex.h:42
luaX_lookahead
LUAI_FUNC int luaX_lookahead(LexState *ls)
Definition:
llex.c:572
TK_SHR
Definition:
llex.h:40
SemInfo::i
lua_Integer i
Definition:
llex.h:51
LexState
struct LexState LexState
TK_CONCAT
Definition:
llex.h:39
LexState::buff
Mbuffer * buff
Definition:
llex.h:73
lua_Number
LUA_NUMBER lua_Number
Definition:
lua.h:90
TK_STRING
Definition:
llex.h:42
LexState::z
ZIO * z
Definition:
llex.h:72
LexState::lastline
int lastline
Definition:
llex.h:67
plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:09