# lua/llex.h File Reference

`#include "lobject.h"`
`#include "lzio.h"`

Include dependency graph for llex.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

union | SemInfo
struct | Token
struct | LexState

## Defines

#define | FIRST_RESERVED 257
#define | TOKEN_LEN (sizeof("function")/sizeof(char))
#define | NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))

## Enumerations

enum | RESERVED { TK_AND = 257, TK_BREAK, TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, TK_NAME, TK_STRING, TK_EOS }

## Functions

void | luaX_init (lua_State *L)
void | luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source)
TString * | luaX_newstring (LexState *ls, const char *str, size_t l)
void | luaX_next (LexState *ls)
void | luaX_lookahead (LexState *ls)
void | luaX_lexerror (LexState *ls, const char *msg, int token)
void | luaX_syntaxerror (LexState *ls, const char *s)
const char * | luaX_token2str (LexState *ls, int token)

## Variables

const char *const | luaX_tokens []

## Define Documentation

#define FIRST_RESERVED 257

Definition at line 14 of file llex.h.

Referenced by llex(), and luaX_token2str().

#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))

Definition at line 36 of file llex.h.

Referenced by luaX_init().

#define TOKEN_LEN (sizeof("function")/sizeof(char))

Definition at line 17 of file llex.h.

Referenced by luaX_init().

## Enumeration Type Documentation

enum RESERVED

Enumerator:

  TK_AND |
  TK_BREAK |
  TK_DO |
  TK_ELSE |
  TK_ELSEIF |
  TK_END |
  TK_FALSE |
  TK_FOR |
  TK_FUNCTION |
  TK_IF |
  TK_IN |
  TK_LOCAL |
  TK_NIL |
  TK_NOT |
  TK_OR |
  TK_REPEAT |
  TK_RETURN |
  TK_THEN |
  TK_TRUE |
  TK_UNTIL |
  TK_WHILE |
  TK_CONCAT |
  TK_DOTS |
  TK_EQ |
  TK_GE |
  TK_LE |
  TK_NE |
  TK_NUMBER |
  TK_NAME |
  TK_STRING |
  TK_EOS |

Definition at line 24 of file llex.h.

## Function Documentation

void luaX_init | ( | lua_State * | L | ) |

Definition at line 64 of file llex.c.

References cast_byte, lua_assert, luaS_fix, luaS_new, luaX_tokens, NUM_RESERVED, TString::reserved, TOKEN_LEN, and TString::tsv.

Referenced by f_luaopen().

void luaX_lexerror | ( | LexState * | ls,
|  | const char * | msg,
|  | int | token |
| ) |  |  |

Definition at line 102 of file llex.c.

References getstr, LexState::L, LexState::linenumber, luaD_throw(), luaO_chunkid(), luaO_pushfstring(), MAXSRC, LexState::source, and txtToken().

Referenced by enterlevel(), errorlimit(), llex(), luaX_syntaxerror(), read_long_string(), read_string(), save(), and trydecpoint().

void luaX_lookahead | ( | LexState * | ls | ) |

Definition at line 457 of file llex.c.

References llex(), LexState::lookahead, lua_assert, Token::seminfo, TK_EOS, and Token::token.

Referenced by constructor().

TString* luaX_newstring | ( | LexState * | ls,
|  | const char * | str,
|  | size_t | l |
| ) |  |  |

Definition at line 117 of file llex.c.

References LexState::fs, FuncState::h, LexState::L, luaH_setstr(), luaS_newlstr(), setbvalue, and ttisnil.

Referenced by anchor_token(), llex(), read_long_string(), and read_string().

void luaX_next | ( | LexState * | ls | ) |

Definition at line 446 of file llex.c.

References LexState::lastline, LexState::linenumber, llex(), LexState::lookahead, Token::seminfo, LexState::t, TK_EOS, and Token::token.

Referenced by checknext(), field(), forstat(), funcargs(), funcstat(), ifstat(), luaY_parser(), parlist(), prefixexp(), primaryexp(), repeatstat(), retstat(), simpleexp(), statement(), str_checkname(), subexpr(), test_then_block(), testnext(), whilestat(), and yindex().

void luaX_setinput | ( | lua_State * | L,
|  | LexState * | ls,
|  | ZIO * | z,
|  | TString * | source |
| ) |  |  |

Definition at line 138 of file llex.c.

References LexState::buff, LexState::decpoint, LexState::fs, LexState::L, LexState::lastline, LexState::linenumber, LexState::lookahead, LUA_MINBUFFER, luaZ_resizebuffer, next, LexState::source, TK_EOS, Token::token, and LexState::z.

Referenced by luaY_parser().

void luaX_syntaxerror | ( | LexState * | ls,
|  | const char * | s |
| ) |  |  |

Definition at line 112 of file llex.c.

References luaX_lexerror(), LexState::t, and Token::token.

Referenced by breakstat(), check_match(), error_expected(), fixjump(), forstat(), funcargs(), inclinenumber(), luaK_checkstack(), parlist(), and prefixexp().

const char* luaX_token2str | ( | LexState * | ls,
|  | int | token |
| ) |  |  |

Definition at line 78 of file llex.c.

References cast, FIRST_RESERVED, LexState::L, lua_assert, luaO_pushfstring(), and luaX_tokens.

Referenced by check_match(), error_expected(), and txtToken().

## Variable Documentation

const char* const luaX_tokens[]

Definition at line 37 of file llex.c.

Referenced by luaX_init(), and luaX_token2str().