3rdparty
lua-5.4.3
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
TK_IF
@ TK_IF
Definition:
llex.h:36
LexState
struct LexState LexState
LexState::fs
struct FuncState * fs
Definition:
llex.h:70
TK_SHR
@ TK_SHR
Definition:
llex.h:40
LUAI_FUNC
#define LUAI_FUNC
Definition:
luaconf.h:312
l_noret
#define l_noret
Definition:
llimits.h:162
LexState::h
Table * h
Definition:
llex.h:74
TString
Definition:
lobject.h:373
TK_THEN
@ TK_THEN
Definition:
llex.h:37
TK_REPEAT
@ TK_REPEAT
Definition:
llex.h:36
TK_NE
@ TK_NE
Definition:
llex.h:39
TK_FLT
@ TK_FLT
Definition:
llex.h:42
luaX_lookahead
LUAI_FUNC int luaX_lookahead(LexState *ls)
Definition:
llex.c:576
Token::token
int token
Definition:
llex.h:57
luaX_token2str
const LUAI_FUNC char * luaX_token2str(LexState *ls, int token)
Definition:
llex.c:82
TK_IDIV
@ TK_IDIV
Definition:
llex.h:39
LexState::source
TString * source
Definition:
llex.h:76
Token
Definition:
llex.h:56
TK_WHILE
@ TK_WHILE
Definition:
llex.h:37
SemInfo::i
lua_Integer i
Definition:
llex.h:51
TK_BREAK
@ TK_BREAK
Definition:
llex.h:34
LexState::current
int current
Definition:
llex.h:65
TK_LOCAL
@ TK_LOCAL
Definition:
llex.h:36
SemInfo::ts
TString * ts
Definition:
llex.h:52
lua_Number
LUA_NUMBER lua_Number
Definition:
lua.h:90
LexState::lookahead
Token lookahead
Definition:
llex.h:69
LexState::envn
TString * envn
Definition:
llex.h:77
LexState::L
struct lua_State * L
Definition:
llex.h:71
TK_ELSE
@ TK_ELSE
Definition:
llex.h:35
FuncState
Definition:
lparser.h:144
TK_DBCOLON
@ TK_DBCOLON
Definition:
llex.h:41
TK_RETURN
@ TK_RETURN
Definition:
llex.h:37
TK_AND
@ TK_AND
Definition:
llex.h:34
mqtt_test_proto.z
z
Definition:
mqtt_test_proto.py:36
luaX_setinput
LUAI_FUNC void luaX_setinput(lua_State *L, LexState *ls, ZIO *z, TString *source, int firstchar)
Definition:
llex.c:167
TK_END
@ TK_END
Definition:
llex.h:35
TK_SHL
@ TK_SHL
Definition:
llex.h:40
TK_UNTIL
@ TK_UNTIL
Definition:
llex.h:37
TK_FALSE
@ TK_FALSE
Definition:
llex.h:35
Token
struct Token Token
Mbuffer
Definition:
lzio.h:23
TK_ELSEIF
@ TK_ELSEIF
Definition:
llex.h:35
TK_NOT
@ TK_NOT
Definition:
llex.h:36
LexState::linenumber
int linenumber
Definition:
llex.h:66
TK_OR
@ TK_OR
Definition:
llex.h:36
FIRST_RESERVED
#define FIRST_RESERVED
Definition:
llex.h:20
LexState::z
ZIO * z
Definition:
llex.h:72
TK_IN
@ TK_IN
Definition:
llex.h:36
lua_State
Definition:
lstate.h:304
luaX_syntaxerror
LUAI_FUNC l_noret luaX_syntaxerror(LexState *ls, const char *s)
Definition:
llex.c:119
TK_EOS
@ TK_EOS
Definition:
llex.h:41
lobject.h
lua_Integer
LUA_INTEGER lua_Integer
Definition:
lua.h:94
source
const char * source
Definition:
lz4.h:767
luaX_newstring
LUAI_FUNC TString * luaX_newstring(LexState *ls, const char *str, size_t l)
Definition:
llex.c:134
RESERVED
RESERVED
Definition:
llex.h:32
TK_GE
@ TK_GE
Definition:
llex.h:39
TK_CONCAT
@ TK_CONCAT
Definition:
llex.h:39
TK_INT
@ TK_INT
Definition:
llex.h:42
LexState::t
Token t
Definition:
llex.h:68
SemInfo
Definition:
llex.h:49
LexState
Definition:
llex.h:64
TK_FOR
@ TK_FOR
Definition:
llex.h:35
TK_GOTO
@ TK_GOTO
Definition:
llex.h:36
SemInfo::r
lua_Number r
Definition:
llex.h:50
LexState::buff
Mbuffer * buff
Definition:
llex.h:73
TK_TRUE
@ TK_TRUE
Definition:
llex.h:37
TK_NIL
@ TK_NIL
Definition:
llex.h:36
TK_DOTS
@ TK_DOTS
Definition:
llex.h:39
luaX_init
LUAI_FUNC void luaX_init(lua_State *L)
Definition:
llex.c:70
TK_DO
@ TK_DO
Definition:
llex.h:35
TK_STRING
@ TK_STRING
Definition:
llex.h:42
TK_NAME
@ TK_NAME
Definition:
llex.h:42
Token::seminfo
SemInfo seminfo
Definition:
llex.h:58
Zio
Definition:
lzio.h:55
lzio.h
Dyndata
Definition:
lparser.h:128
luaX_next
LUAI_FUNC void luaX_next(LexState *ls)
Definition:
llex.c:565
LexState::lastline
int lastline
Definition:
llex.h:67
Table
Definition:
lobject.h:724
TK_EQ
@ TK_EQ
Definition:
llex.h:39
LexState::dyd
struct Dyndata * dyd
Definition:
llex.h:75
TK_FUNCTION
@ TK_FUNCTION
Definition:
llex.h:35
TK_LE
@ TK_LE
Definition:
llex.h:39
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44