lua/llex.h

Go to the documentation of this file.
00001 /*
00002 ** $Id: llex.h,v 1.72 2011/11/30 12:43:51 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 
00017 
00018 /*
00019 * WARNING: if you change the order of this enumeration,
00020 * grep "ORDER RESERVED"
00021 */
00022 enum RESERVED {
00023   /* terminal symbols denoted by reserved words */
00024   TK_AND = FIRST_RESERVED, TK_BREAK,
00025   TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
00026   TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
00027   TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
00028   /* other terminal symbols */
00029   TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS,
00030   TK_NUMBER, TK_NAME, TK_STRING
00031 };
00032 
00033 /* number of reserved words */
00034 #define NUM_RESERVED    (cast(int, TK_WHILE-FIRST_RESERVED+1))
00035 
00036 
00037 typedef union {
00038   lua_Number r;
00039   TString *ts;
00040 } SemInfo;  /* semantics information */
00041 
00042 
00043 typedef struct Token {
00044   int token;
00045   SemInfo seminfo;
00046 } Token;
00047 
00048 
00049 /* state of the lexer plus state of the parser when shared by all
00050    functions */
00051 typedef struct LexState {
00052   int current;  /* current character (charint) */
00053   int linenumber;  /* input line counter */
00054   int lastline;  /* line of last token `consumed' */
00055   Token t;  /* current token */
00056   Token lookahead;  /* look ahead token */
00057   struct FuncState *fs;  /* current function (parser) */
00058   struct lua_State *L;
00059   ZIO *z;  /* input stream */
00060   Mbuffer *buff;  /* buffer for tokens */
00061   struct Dyndata *dyd;  /* dynamic structures used by the parser */
00062   TString *source;  /* current source name */
00063   TString *envn;  /* environment variable name */
00064   char decpoint;  /* locale decimal point */
00065 } LexState;
00066 
00067 
00068 LUAI_FUNC void luaX_init (lua_State *L);
00069 LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
00070                               TString *source, int firstchar);
00071 LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
00072 LUAI_FUNC void luaX_next (LexState *ls);
00073 LUAI_FUNC int luaX_lookahead (LexState *ls);
00074 LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s);
00075 LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
00076 
00077 
00078 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:04 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs