llex.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef llex_h
00008 #define llex_h
00009
00010 #include "lobject.h"
00011 #include "lzio.h"
00012
00013
00014 #define FIRST_RESERVED 257
00015
00016
00017 #define TOKEN_LEN (sizeof("function")/sizeof(char))
00018
00019
00020
00021
00022
00023
00024 enum RESERVED {
00025
00026 TK_AND = FIRST_RESERVED, TK_BREAK,
00027 TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
00028 TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
00029 TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
00030
00031 TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
00032 TK_NAME, TK_STRING, TK_EOS
00033 };
00034
00035
00036 #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
00037
00038
00039
00040 LUAI_DATA const char *const luaX_tokens [];
00041
00042
00043 typedef union {
00044 lua_Number r;
00045 TString *ts;
00046 } SemInfo;
00047
00048
00049 typedef struct Token {
00050 int token;
00051 SemInfo seminfo;
00052 } Token;
00053
00054
00055 typedef struct LexState {
00056 int current;
00057 int linenumber;
00058 int lastline;
00059 Token t;
00060 Token lookahead;
00061 struct FuncState *fs;
00062 struct lua_State *L;
00063 ZIO *z;
00064 Mbuffer *buff;
00065 TString *source;
00066 char decpoint;
00067 } LexState;
00068
00069
00070 LUAI_FUNC void luaX_init (lua_State *L);
00071 LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
00072 TString *source);
00073 LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
00074 LUAI_FUNC void luaX_next (LexState *ls);
00075 LUAI_FUNC void luaX_lookahead (LexState *ls);
00076 LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);
00077 LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
00078 LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
00079
00080
00081 #endif