1*eda14cbcSMatt Macy /* BEGIN CSTYLED */ 2*eda14cbcSMatt Macy /* 3*eda14cbcSMatt Macy ** $Id: llex.h,v 1.72.1.1 2013/04/12 18:48:47 roberto Exp $ 4*eda14cbcSMatt Macy ** Lexical Analyzer 5*eda14cbcSMatt Macy ** See Copyright Notice in lua.h 6*eda14cbcSMatt Macy */ 7*eda14cbcSMatt Macy 8*eda14cbcSMatt Macy #ifndef llex_h 9*eda14cbcSMatt Macy #define llex_h 10*eda14cbcSMatt Macy 11*eda14cbcSMatt Macy #include "lobject.h" 12*eda14cbcSMatt Macy #include "lzio.h" 13*eda14cbcSMatt Macy 14*eda14cbcSMatt Macy 15*eda14cbcSMatt Macy #define FIRST_RESERVED 257 16*eda14cbcSMatt Macy 17*eda14cbcSMatt Macy 18*eda14cbcSMatt Macy 19*eda14cbcSMatt Macy /* 20*eda14cbcSMatt Macy * WARNING: if you change the order of this enumeration, 21*eda14cbcSMatt Macy * grep "ORDER RESERVED" 22*eda14cbcSMatt Macy */ 23*eda14cbcSMatt Macy enum RESERVED { 24*eda14cbcSMatt Macy /* terminal symbols denoted by reserved words */ 25*eda14cbcSMatt Macy TK_AND = FIRST_RESERVED, TK_BREAK, 26*eda14cbcSMatt Macy TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 27*eda14cbcSMatt Macy TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 28*eda14cbcSMatt Macy TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 29*eda14cbcSMatt Macy /* other terminal symbols */ 30*eda14cbcSMatt Macy TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS, 31*eda14cbcSMatt Macy TK_NUMBER, TK_NAME, TK_STRING 32*eda14cbcSMatt Macy }; 33*eda14cbcSMatt Macy 34*eda14cbcSMatt Macy /* number of reserved words */ 35*eda14cbcSMatt Macy #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 36*eda14cbcSMatt Macy 37*eda14cbcSMatt Macy 38*eda14cbcSMatt Macy typedef union { 39*eda14cbcSMatt Macy lua_Number r; 40*eda14cbcSMatt Macy TString *ts; 41*eda14cbcSMatt Macy } SemInfo; /* semantics information */ 42*eda14cbcSMatt Macy 43*eda14cbcSMatt Macy 44*eda14cbcSMatt Macy typedef struct Token { 45*eda14cbcSMatt Macy int token; 46*eda14cbcSMatt Macy SemInfo seminfo; 47*eda14cbcSMatt Macy } Token; 48*eda14cbcSMatt Macy 49*eda14cbcSMatt Macy #ifdef current 50*eda14cbcSMatt Macy #undef current 51*eda14cbcSMatt Macy #endif 52*eda14cbcSMatt Macy 53*eda14cbcSMatt Macy /* state of the lexer plus state of the parser when shared by all 54*eda14cbcSMatt Macy functions */ 55*eda14cbcSMatt Macy typedef struct LexState { 56*eda14cbcSMatt Macy int current; /* current character (charint) */ 57*eda14cbcSMatt Macy int linenumber; /* input line counter */ 58*eda14cbcSMatt Macy int lastline; /* line of last token `consumed' */ 59*eda14cbcSMatt Macy Token t; /* current token */ 60*eda14cbcSMatt Macy Token lookahead; /* look ahead token */ 61*eda14cbcSMatt Macy struct FuncState *fs; /* current function (parser) */ 62*eda14cbcSMatt Macy struct lua_State *L; 63*eda14cbcSMatt Macy ZIO *z; /* input stream */ 64*eda14cbcSMatt Macy Mbuffer *buff; /* buffer for tokens */ 65*eda14cbcSMatt Macy struct Dyndata *dyd; /* dynamic structures used by the parser */ 66*eda14cbcSMatt Macy TString *source; /* current source name */ 67*eda14cbcSMatt Macy TString *envn; /* environment variable name */ 68*eda14cbcSMatt Macy char decpoint; /* locale decimal point */ 69*eda14cbcSMatt Macy } LexState; 70*eda14cbcSMatt Macy 71*eda14cbcSMatt Macy 72*eda14cbcSMatt Macy LUAI_FUNC void luaX_init (lua_State *L); 73*eda14cbcSMatt Macy LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 74*eda14cbcSMatt Macy TString *source, int firstchar); 75*eda14cbcSMatt Macy LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 76*eda14cbcSMatt Macy LUAI_FUNC void luaX_next (LexState *ls); 77*eda14cbcSMatt Macy LUAI_FUNC int luaX_lookahead (LexState *ls); 78*eda14cbcSMatt Macy LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 79*eda14cbcSMatt Macy LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 80*eda14cbcSMatt Macy 81*eda14cbcSMatt Macy 82*eda14cbcSMatt Macy #endif 83*eda14cbcSMatt Macy /* END CSTYLED */ 84