The Battle for Wesnoth  1.15.2+dev
Macros | Functions | Variables
llex.cpp File Reference
#include "lprefix.h"
#include <locale.h>
#include <string.h>
#include "lua.h"
#include "lctype.h"
#include "ldebug.h"
#include "ldo.h"
#include "lgc.h"
#include "llex.h"
#include "lobject.h"
#include "lparser.h"
#include "lstate.h"
#include "lstring.h"
#include "ltable.h"
#include "lzio.h"
Include dependency graph for llex.cpp:

Go to the source code of this file.

Macros

#define llex_c
 
#define LUA_CORE
 
#define next(ls)   (ls->current = zgetc(ls->z))
 
#define currIsNewline(ls)   (ls->current == '\n' || ls->current == '\r')
 
#define save_and_next(ls)   (save(ls, ls->current), next(ls))
 

Functions

static l_noret lexerror (LexState *ls, const char *msg, int token)
 
static void save (LexState *ls, int c)
 
void luaX_init (lua_State *L)
 
const char * luaX_token2str (LexState *ls, int token)
 
static const char * txtToken (LexState *ls, int token)
 
l_noret luaX_syntaxerror (LexState *ls, const char *msg)
 
TStringluaX_newstring (LexState *ls, const char *str, size_t l)
 
static void inclinenumber (LexState *ls)
 
void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source, int firstchar)
 
static int check_next1 (LexState *ls, int c)
 
static int check_next2 (LexState *ls, const char *set)
 
static int read_numeral (LexState *ls, SemInfo *seminfo)
 
static int skip_sep (LexState *ls)
 
static void read_long_string (LexState *ls, SemInfo *seminfo, int sep)
 
static void esccheck (LexState *ls, int c, const char *msg)
 
static int gethexa (LexState *ls)
 
static int readhexaesc (LexState *ls)
 
static unsigned long readutf8esc (LexState *ls)
 
static void utf8esc (LexState *ls)
 
static int readdecesc (LexState *ls)
 
static void read_string (LexState *ls, int del, SemInfo *seminfo)
 
static int llex (LexState *ls, SemInfo *seminfo)
 
void luaX_next (LexState *ls)
 
int luaX_lookahead (LexState *ls)
 

Variables

static const char *const luaX_tokens []
 

Macro Definition Documentation

◆ currIsNewline

#define currIsNewline (   ls)    (ls->current == '\n' || ls->current == '\r')

Definition at line 36 of file llex.cpp.

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

◆ llex_c

#define llex_c

Definition at line 7 of file llex.cpp.

◆ LUA_CORE

#define LUA_CORE

Definition at line 8 of file llex.cpp.

◆ next

#define next (   ls)    (ls->current = zgetc(ls->z))

◆ save_and_next

#define save_and_next (   ls)    (save(ls, ls->current), next(ls))

Function Documentation

◆ check_next1()

static int check_next1 ( LexState ls,
int  c 
)
static

Definition at line 186 of file llex.cpp.

References LexState::current, and next.

Referenced by llex().

◆ check_next2()

static int check_next2 ( LexState ls,
const char *  set 
)
static

Definition at line 199 of file llex.cpp.

References LexState::current, lua_assert, and save_and_next.

Referenced by read_numeral().

◆ esccheck()

static void esccheck ( LexState ls,
int  c,
const char *  msg 
)
static

Definition at line 303 of file llex.cpp.

References LexState::current, EOZ, lexerror(), save_and_next, and TK_STRING.

Referenced by gethexa(), read_string(), readdecesc(), and readutf8esc().

◆ gethexa()

static int gethexa ( LexState ls)
static

Definition at line 312 of file llex.cpp.

References LexState::current, esccheck(), lisxdigit, luaO_hexavalue(), and save_and_next.

Referenced by readhexaesc(), and readutf8esc().

◆ inclinenumber()

static void inclinenumber ( LexState ls)
static

◆ lexerror()

static l_noret lexerror ( LexState ls,
const char *  msg,
int  token 
)
static

◆ llex()

static int llex ( LexState ls,
SemInfo seminfo 
)
static

◆ luaX_init()

void luaX_init ( lua_State L)

Definition at line 70 of file llex.cpp.

References cast_byte, e, TString::extra, i, LUA_ENV, luaC_fix(), luaS_new(), luaS_newliteral, luaX_tokens, NUM_RESERVED, and obj2gco.

Referenced by f_luaopen().

◆ luaX_lookahead()

int luaX_lookahead ( LexState ls)

Definition at line 560 of file llex.cpp.

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

Referenced by field().

◆ luaX_newstring()

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

◆ luaX_next()

void luaX_next ( LexState ls)

◆ luaX_setinput()

void luaX_setinput ( lua_State L,
LexState ls,
ZIO z,
TString source,
int  firstchar 
)

◆ luaX_syntaxerror()

l_noret luaX_syntaxerror ( LexState ls,
const char *  msg 
)

◆ luaX_token2str()

const char* luaX_token2str ( LexState ls,
int  token 
)

◆ read_long_string()

static void read_long_string ( LexState ls,
SemInfo seminfo,
int  sep 
)
static

◆ read_numeral()

static int read_numeral ( LexState ls,
SemInfo seminfo 
)
static

◆ read_string()

static void read_string ( LexState ls,
int  del,
SemInfo seminfo 
)
static

◆ readdecesc()

static int readdecesc ( LexState ls)
static

Definition at line 353 of file llex.cpp.

References LexState::buff, LexState::current, esccheck(), i, lisdigit, luaZ_buffremove, and save_and_next.

Referenced by read_string().

◆ readhexaesc()

static int readhexaesc ( LexState ls)
static

Definition at line 319 of file llex.cpp.

References LexState::buff, gethexa(), and luaZ_buffremove.

Referenced by read_string().

◆ readutf8esc()

static unsigned long readutf8esc ( LexState ls)
static

◆ save()

static void save ( LexState ls,
int  c 
)
static

◆ skip_sep()

static int skip_sep ( LexState ls)
static

Definition at line 251 of file llex.cpp.

References LexState::current, lua_assert, s, and save_and_next.

Referenced by llex(), and read_long_string().

◆ txtToken()

static const char* txtToken ( LexState ls,
int  token 
)
static

◆ utf8esc()

static void utf8esc ( LexState ls)
static

Definition at line 345 of file llex.cpp.

References luaO_utf8esc(), n, readutf8esc(), save(), and UTF8BUFFSZ.

Referenced by read_string().

Variable Documentation

◆ luaX_tokens

const char* const luaX_tokens[]
static
Initial value:
= {
"and", "break", "do", "else", "elseif",
"end", "false", "for", "function", "goto", "if",
"in", "local", "nil", "not", "or", "repeat",
"return", "then", "true", "until", "while",
"//", "..", "...", "==", ">=", "<=", "~=",
"<<", ">>", "::", "<eof>",
"<number>", "<integer>", "<name>", "<string>"
}

Definition at line 40 of file llex.cpp.

Referenced by luaX_init(), and luaX_token2str().