sdk-world
v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Toggle main menu visibility
Loading...
Searching...
No Matches
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
11
#ifndef llex_h
12
#define llex_h
13
14
#include <limits.h>
15
16
#include "
lobject.h
"
17
#include "
lzio.h
"
18
19
20
/*
21
** Single-char tokens (terminal symbols) are represented by their own
22
** numeric code. Other tokens start at the following value.
23
*/
24
#define FIRST_RESERVED (UCHAR_MAX + 1)
25
26
27
#if !defined(LUA_ENV)
28
#define LUA_ENV "_ENV"
29
#endif
30
31
32
/*
33
* WARNING: if you change the order of this enumeration,
34
* grep "ORDER RESERVED"
35
*/
36
enum
RESERVED {
37
/* terminal symbols denoted by reserved words */
38
TK_AND = FIRST_RESERVED, TK_BREAK,
39
TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
40
TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
41
TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
42
/* other terminal symbols */
43
TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE,
44
TK_SHL, TK_SHR,
45
TK_DBCOLON, TK_EOS,
46
TK_FLT, TK_INT, TK_NAME, TK_STRING
47
};
48
49
/* number of reserved words */
50
#define NUM_RESERVED (cast_int(TK_WHILE-FIRST_RESERVED + 1))
51
52
53
typedef
union
{
54
lua_Number r;
55
lua_Integer i;
56
TString
*ts;
57
}
SemInfo
;
/* semantics information */
58
59
60
typedef
struct
Token
{
61
int
token;
62
SemInfo
seminfo;
63
}
Token
;
64
65
66
/* state of the lexer plus state of the parser when shared by all
67
functions */
68
typedef
struct
LexState
{
69
int
current;
/* current character (charint) */
70
int
linenumber;
/* input line counter */
71
int
lastline;
/* line of last token 'consumed' */
72
Token
t;
/* current token */
73
Token
lookahead;
/* look ahead token */
74
struct
FuncState
*fs;
/* current function (parser) */
75
struct
lua_State
*L;
76
ZIO *z;
/* input stream */
77
Mbuffer
*buff;
/* buffer for tokens */
78
Table
*h;
/* to avoid collection/reuse strings */
79
struct
Dyndata
*dyd;
/* dynamic structures used by the parser */
80
TString
*source;
/* current source name */
81
TString
*envn;
/* environment variable name */
82
}
LexState
;
83
84
85
LUAI_FUNC
void
luaX_init (
lua_State
*L);
86
LUAI_FUNC
void
luaX_setinput (
lua_State
*L,
LexState
*ls, ZIO *z,
87
TString
*source,
int
firstchar);
88
LUAI_FUNC
TString
*luaX_newstring (
LexState
*ls,
const
char
*str,
size_t
l);
89
LUAI_FUNC
void
luaX_next (
LexState
*ls);
90
LUAI_FUNC
int
luaX_lookahead (
LexState
*ls);
91
LUAI_FUNC l_noret luaX_syntaxerror (
LexState
*ls,
const
char
*s);
92
LUAI_FUNC
const
char
*luaX_token2str (
LexState
*ls,
int
token);
93
94
95
#endif
lobject.h
lzio.h
Dyndata
Definition
lparser.h:132
FuncState
Definition
lparser.h:148
LexState
Definition
llex.h:68
Mbuffer
Definition
lzio.h:27
TString
Definition
lobject.h:390
Table
Definition
lobject.h:743
Token
Definition
llex.h:60
lua_State
Definition
lstate.h:313
SemInfo
Definition
llex.h:53
lua
src
llex.h
Generated by
1.18.0