annotate src/lua/llex.h @ 29:2fa26addb901

added version.h
author Robert McIntyre <rlm@mit.edu>
date Sun, 04 Mar 2012 21:09:22 -0600
parents 27763b933818
children
rev   line source
rlm@1 1 /*
rlm@1 2 ** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
rlm@1 3 ** Lexical Analyzer
rlm@1 4 ** See Copyright Notice in lua.h
rlm@1 5 */
rlm@1 6
rlm@1 7 #ifndef llex_h
rlm@1 8 #define llex_h
rlm@1 9
rlm@1 10 #include "lobject.h"
rlm@1 11 #include "lzio.h"
rlm@1 12
rlm@1 13
rlm@1 14 #define FIRST_RESERVED 257
rlm@1 15
rlm@1 16 /* maximum length of a reserved word */
rlm@1 17 #define TOKEN_LEN (sizeof("function")/sizeof(char))
rlm@1 18
rlm@1 19
rlm@1 20 /*
rlm@1 21 * WARNING: if you change the order of this enumeration,
rlm@1 22 * grep "ORDER RESERVED"
rlm@1 23 */
rlm@1 24 enum RESERVED {
rlm@1 25 /* terminal symbols denoted by reserved words */
rlm@1 26 TK_AND = FIRST_RESERVED, TK_BREAK,
rlm@1 27 TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
rlm@1 28 TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
rlm@1 29 TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
rlm@1 30 /* other terminal symbols */
rlm@1 31 TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
rlm@1 32 TK_NAME, TK_STRING, TK_EOS
rlm@1 33 };
rlm@1 34
rlm@1 35 /* number of reserved words */
rlm@1 36 #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
rlm@1 37
rlm@1 38
rlm@1 39 /* array with token `names' */
rlm@1 40 LUAI_DATA const char *const luaX_tokens [];
rlm@1 41
rlm@1 42
rlm@1 43 typedef union {
rlm@1 44 lua_Number r;
rlm@1 45 TString *ts;
rlm@1 46 } SemInfo; /* semantics information */
rlm@1 47
rlm@1 48
rlm@1 49 typedef struct Token {
rlm@1 50 int token;
rlm@1 51 SemInfo seminfo;
rlm@1 52 } Token;
rlm@1 53
rlm@1 54
rlm@1 55 typedef struct LexState {
rlm@1 56 int current; /* current character (charint) */
rlm@1 57 int linenumber; /* input line counter */
rlm@1 58 int lastline; /* line of last token `consumed' */
rlm@1 59 Token t; /* current token */
rlm@1 60 Token lookahead; /* look ahead token */
rlm@1 61 struct FuncState *fs; /* `FuncState' is private to the parser */
rlm@1 62 struct lua_State *L;
rlm@1 63 ZIO *z; /* input stream */
rlm@1 64 Mbuffer *buff; /* buffer for tokens */
rlm@1 65 TString *source; /* current source name */
rlm@1 66 char decpoint; /* locale decimal point */
rlm@1 67 } LexState;
rlm@1 68
rlm@1 69
rlm@1 70 LUAI_FUNC void luaX_init (lua_State *L);
rlm@1 71 LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
rlm@1 72 TString *source);
rlm@1 73 LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
rlm@1 74 LUAI_FUNC void luaX_next (LexState *ls);
rlm@1 75 LUAI_FUNC void luaX_lookahead (LexState *ls);
rlm@1 76 LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);
rlm@1 77 LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
rlm@1 78 LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
rlm@1 79
rlm@1 80
rlm@1 81 #endif