diff options
| author | Li Jin <dragon-fly@qq.com> | 2021-04-21 09:36:25 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2021-04-21 09:36:25 +0800 |
| commit | b7bdf7d5d36825a1a750a74641f6d374dec5d67a (patch) | |
| tree | 6b27eb6590e07c07f378305c51d0f5e0779faa83 /src/3rdParty/lua/llex.h | |
| parent | b86e5af605a170a3559df0165eac3cb6b665dc49 (diff) | |
| download | yuescript-b7bdf7d5d36825a1a750a74641f6d374dec5d67a.tar.gz yuescript-b7bdf7d5d36825a1a750a74641f6d374dec5d67a.tar.bz2 yuescript-b7bdf7d5d36825a1a750a74641f6d374dec5d67a.zip | |
adjust some folder levels.
Diffstat (limited to 'src/3rdParty/lua/llex.h')
| -rw-r--r-- | src/3rdParty/lua/llex.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/3rdParty/lua/llex.h b/src/3rdParty/lua/llex.h new file mode 100644 index 0000000..389d2f8 --- /dev/null +++ b/src/3rdParty/lua/llex.h | |||
| @@ -0,0 +1,91 @@ | |||
| 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 | ||
