Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/contrib/openzfs/module/lua/llex.h
48383 views
1
// SPDX-License-Identifier: MIT
2
/*
3
** $Id: llex.h,v 1.72.1.1 2013/04/12 18:48:47 roberto Exp $
4
** Lexical Analyzer
5
** See Copyright Notice in lua.h
6
*/
7
8
#ifndef llex_h
9
#define llex_h
10
11
#include "lobject.h"
12
#include "lzio.h"
13
14
15
#define FIRST_RESERVED 257
16
17
18
19
/*
20
* WARNING: if you change the order of this enumeration,
21
* grep "ORDER RESERVED"
22
*/
23
enum RESERVED {
24
/* terminal symbols denoted by reserved words */
25
TK_AND = FIRST_RESERVED, TK_BREAK,
26
TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
27
TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
28
TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
29
/* other terminal symbols */
30
TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS,
31
TK_NUMBER, TK_NAME, TK_STRING
32
};
33
34
/* number of reserved words */
35
#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
36
37
38
typedef union {
39
lua_Number r;
40
TString *ts;
41
} SemInfo; /* semantics information */
42
43
44
typedef struct Token {
45
int token;
46
SemInfo seminfo;
47
} Token;
48
49
#ifdef current
50
#undef current
51
#endif
52
53
/* state of the lexer plus state of the parser when shared by all
54
functions */
55
typedef struct LexState {
56
int current; /* current character (charint) */
57
int linenumber; /* input line counter */
58
int lastline; /* line of last token `consumed' */
59
Token t; /* current token */
60
Token lookahead; /* look ahead token */
61
struct FuncState *fs; /* current function (parser) */
62
struct lua_State *L;
63
ZIO *z; /* input stream */
64
Mbuffer *buff; /* buffer for tokens */
65
struct Dyndata *dyd; /* dynamic structures used by the parser */
66
TString *source; /* current source name */
67
TString *envn; /* environment variable name */
68
char decpoint; /* locale decimal point */
69
} LexState;
70
71
72
LUAI_FUNC void luaX_init (lua_State *L);
73
LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
74
TString *source, int firstchar);
75
LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
76
LUAI_FUNC void luaX_next (LexState *ls);
77
LUAI_FUNC int luaX_lookahead (LexState *ls);
78
LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s);
79
LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
80
81
82
#endif
83
84