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