rpm
4.5
|
00001 /* 00002 ** $Id: llex.h,v 1.1 2004/03/16 21:58:30 niemeyer 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_NAME, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, 00032 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 typedef union { 00040 lua_Number r; 00041 /*@null@*/ 00042 TString *ts; 00043 } SemInfo; /* semantics information */ 00044 00045 00046 typedef struct Token { 00047 int token; 00048 SemInfo seminfo; 00049 } Token; 00050 00051 00052 typedef struct LexState { 00053 int current; /* current character (charint) */ 00054 int linenumber; /* input line counter */ 00055 int lastline; /* line of last token `consumed' */ 00056 Token t; /* current token */ 00057 Token lookahead; /* look ahead token */ 00058 struct FuncState *fs; /* `FuncState' is private to the parser */ 00059 struct lua_State *L; 00060 ZIO *z; /* input stream */ 00061 Mbuffer *buff; /* buffer for tokens */ 00062 TString *source; /* current source name */ 00063 int nestlevel; /* level of nested non-terminals */ 00064 } LexState; 00065 00066 00067 void luaX_init (lua_State *L) 00068 /*@modifies L @*/; 00069 void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source) 00070 /*@modifies LS, z @*/; 00071 int luaX_lex (LexState *LS, SemInfo *seminfo) 00072 /*@modifies LS, seminfo @*/; 00073 void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) 00074 /*@modifies ls @*/; 00075 void luaX_syntaxerror (LexState *ls, const char *s) 00076 /*@modifies ls @*/; 00077 void luaX_errorline (LexState *ls, const char *s, const char *token, int line) 00078 /*@modifies ls @*/; 00079 /*@observer@*/ 00080 const char *luaX_token2str (LexState *ls, int token) 00081 /*@modifies ls @*/; 00082 00083 00084 #endif