00001 /* 00002 ** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ 00003 ** Lexical Analyzer 00004 ** See Copyright Notice in lua.h 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 /* maximum length of a reserved word */ 00017 #define TOKEN_LEN (sizeof("function")/sizeof(char)) 00018 00019 00020 /* 00021 * WARNING: if you change the order of this enumeration, 00022 * grep "ORDER RESERVED" 00023 */ 00024 enum RESERVED { 00025 /* terminal symbols denoted by reserved words */ 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 /* other terminal symbols */ 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 /* number of reserved words */ 00036 #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 00037 00038 00039 /* array with token `names' */ 00040 LUAI_DATA const char *const luaX_tokens []; 00041 00042 00043 typedef union { 00044 lua_Number r; 00045 TString *ts; 00046 } SemInfo; /* semantics information */ 00047 00048 00049 typedef struct Token { 00050 int token; 00051 SemInfo seminfo; 00052 } Token; 00053 00054 00055 typedef struct LexState { 00056 int current; /* current character (charint) */ 00057 int linenumber; /* input line counter */ 00058 int lastline; /* line of last token `consumed' */ 00059 Token t; /* current token */ 00060 Token lookahead; /* look ahead token */ 00061 struct FuncState *fs; /* `FuncState' is private to the parser */ 00062 struct lua_State *L; 00063 ZIO *z; /* input stream */ 00064 Mbuffer *buff; /* buffer for tokens */ 00065 TString *source; /* current source name */ 00066 char decpoint; /* locale decimal point */ 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
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:54 2011 by Doxygen 1.6.1