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_NAME, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
00032 TK_STRING, TK_EOS
00033 };
00034
00035
00036 #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
00037
00038
00039 typedef union {
00040 lua_Number r;
00041
00042 TString *ts;
00043 } SemInfo;
00044
00045
00046 typedef struct Token {
00047 int token;
00048 SemInfo seminfo;
00049 } Token;
00050
00051
00052 typedef struct LexState {
00053 int current;
00054 int linenumber;
00055 int lastline;
00056 Token t;
00057 Token lookahead;
00058 struct FuncState *fs;
00059 struct lua_State *L;
00060 ZIO *z;
00061 Mbuffer *buff;
00062 TString *source;
00063 int nestlevel;
00064 } LexState;
00065
00066
00067 void luaX_init (lua_State *L)
00068 ;
00069 void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source)
00070 ;
00071 int luaX_lex (LexState *LS, SemInfo *seminfo)
00072 ;
00073 void luaX_checklimit (LexState *ls, int val, int limit, const char *msg)
00074 ;
00075 void luaX_syntaxerror (LexState *ls, const char *s)
00076 ;
00077 void luaX_errorline (LexState *ls, const char *s, const char *token, int line)
00078 ;
00079
00080 const char *luaX_token2str (LexState *ls, int token)
00081 ;
00082
00083
00084 #endif