diff options
Diffstat (limited to 'apps/plugins/lua/llex.h')
-rw-r--r-- | apps/plugins/lua/llex.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/apps/plugins/lua/llex.h b/apps/plugins/lua/llex.h index a4acdd3021..fa8b7a2a28 100644 --- a/apps/plugins/lua/llex.h +++ b/apps/plugins/lua/llex.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.h,v 1.72.1.1 2013/04/12 18:48:47 roberto Exp $ | 2 | ** $Id$ |
3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -13,6 +13,8 @@ | |||
13 | 13 | ||
14 | #define FIRST_RESERVED 257 | 14 | #define FIRST_RESERVED 257 |
15 | 15 | ||
16 | /* maximum length of a reserved word */ | ||
17 | #define TOKEN_LEN (sizeof("function")/sizeof(char)) | ||
16 | 18 | ||
17 | 19 | ||
18 | /* | 20 | /* |
@@ -23,17 +25,21 @@ enum RESERVED { | |||
23 | /* terminal symbols denoted by reserved words */ | 25 | /* terminal symbols denoted by reserved words */ |
24 | TK_AND = FIRST_RESERVED, TK_BREAK, | 26 | TK_AND = FIRST_RESERVED, TK_BREAK, |
25 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, | 27 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, |
26 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, | 28 | TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, |
27 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, | 29 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, |
28 | /* other terminal symbols */ | 30 | /* other terminal symbols */ |
29 | TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS, | 31 | TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, |
30 | TK_NUMBER, TK_NAME, TK_STRING | 32 | TK_NAME, TK_STRING, TK_EOS |
31 | }; | 33 | }; |
32 | 34 | ||
33 | /* number of reserved words */ | 35 | /* number of reserved words */ |
34 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) | 36 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) |
35 | 37 | ||
36 | 38 | ||
39 | /* array with token `names' */ | ||
40 | LUAI_DATA const char *const luaX_tokens []; | ||
41 | |||
42 | |||
37 | typedef union { | 43 | typedef union { |
38 | lua_Number r; | 44 | lua_Number r; |
39 | TString *ts; | 45 | TString *ts; |
@@ -46,32 +52,29 @@ typedef struct Token { | |||
46 | } Token; | 52 | } Token; |
47 | 53 | ||
48 | 54 | ||
49 | /* state of the lexer plus state of the parser when shared by all | ||
50 | functions */ | ||
51 | typedef struct LexState { | 55 | typedef struct LexState { |
52 | int current; /* current character (charint) */ | 56 | int current; /* current character (charint) */ |
53 | int linenumber; /* input line counter */ | 57 | int linenumber; /* input line counter */ |
54 | int lastline; /* line of last token `consumed' */ | 58 | int lastline; /* line of last token `consumed' */ |
55 | Token t; /* current token */ | 59 | Token t; /* current token */ |
56 | Token lookahead; /* look ahead token */ | 60 | Token lookahead; /* look ahead token */ |
57 | struct FuncState *fs; /* current function (parser) */ | 61 | struct FuncState *fs; /* `FuncState' is private to the parser */ |
58 | struct lua_State *L; | 62 | struct lua_State *L; |
59 | ZIO *z; /* input stream */ | 63 | ZIO *z; /* input stream */ |
60 | Mbuffer *buff; /* buffer for tokens */ | 64 | Mbuffer *buff; /* buffer for tokens */ |
61 | struct Dyndata *dyd; /* dynamic structures used by the parser */ | ||
62 | TString *source; /* current source name */ | 65 | TString *source; /* current source name */ |
63 | TString *envn; /* environment variable name */ | ||
64 | char decpoint; /* locale decimal point */ | 66 | char decpoint; /* locale decimal point */ |
65 | } LexState; | 67 | } LexState; |
66 | 68 | ||
67 | 69 | ||
68 | LUAI_FUNC void luaX_init (lua_State *L); | 70 | LUAI_FUNC void luaX_init (lua_State *L); |
69 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, | 71 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, |
70 | TString *source, int firstchar); | 72 | TString *source); |
71 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); | 73 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); |
72 | LUAI_FUNC void luaX_next (LexState *ls); | 74 | LUAI_FUNC void luaX_next (LexState *ls); |
73 | LUAI_FUNC int luaX_lookahead (LexState *ls); | 75 | LUAI_FUNC void luaX_lookahead (LexState *ls); |
74 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); | 76 | LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); |
77 | LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); | ||
75 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); | 78 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); |
76 | 79 | ||
77 | 80 | ||