Defines | Functions | Variables

lua/llex.c File Reference

#include <locale.h>
#include <string.h>
#include "lua.h"
#include "lctype.h"
#include "ldo.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.c:

Go to the source code of this file.

Defines

#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))
#define getlocaledecpoint()   (localeconv()->decimal_point[0])
#define buff2d(b, e)   luaO_str2d(luaZ_buffer(b), luaZ_bufflen(b) - 1, e)

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_next (LexState *ls, const char *set)
static void buffreplace (LexState *ls, char from, char to)
static void trydecpoint (LexState *ls, SemInfo *seminfo)
static void 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 escerror (LexState *ls, int *c, int n, const char *msg)
static int readhexaesc (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 []

Define Documentation

#define buff2d (   b,
  e 
)    luaO_str2d(luaZ_buffer(b), luaZ_bufflen(b) - 1, e)

Definition at line 206 of file llex.c.

Referenced by read_numeral(), and trydecpoint().

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

Definition at line 32 of file llex.c.

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

#define getlocaledecpoint (  )     (localeconv()->decimal_point[0])

Definition at line 202 of file llex.c.

Referenced by trydecpoint().

#define llex_c

Definition at line 11 of file llex.c.

#define LUA_CORE

Definition at line 12 of file llex.c.

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

Definition at line 46 of file llex.c.

Referenced by check_next(), llex(), read_long_string(), read_numeral(), read_string(), and skip_sep().


Function Documentation

static void buffreplace ( LexState ls,
char  from,
char  to 
) [static]

Definition at line 193 of file llex.c.

References LexState::buff, luaZ_buffer, and luaZ_bufflen.

Referenced by read_numeral(), and trydecpoint().

Here is the caller graph for this function:

static int check_next ( LexState ls,
const char *  set 
) [static]

Definition at line 182 of file llex.c.

References LexState::current, and save_and_next.

Referenced by llex(), and read_numeral().

Here is the caller graph for this function:

static void escerror ( LexState ls,
int *  c,
int  n,
const char *  msg 
) [static]

Definition at line 291 of file llex.c.

References LexState::buff, lexerror(), luaZ_resetbuffer, save(), and TK_STRING.

Referenced by read_string(), readdecesc(), and readhexaesc().

Here is the call graph for this function:

Here is the caller graph for this function:

static void inclinenumber ( LexState ls  )  [static]

Definition at line 145 of file llex.c.

References LexState::current, currIsNewline, LexState::linenumber, lua_assert, luaX_syntaxerror(), MAX_INT, and next.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 104 of file llex.c.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

static int llex ( LexState ls,
SemInfo seminfo 
) [static]
void luaX_init ( lua_State L  ) 

Definition at line 65 of file llex.c.

References cast_byte, luaS_fix, luaS_new(), luaX_tokens, TString::reserved, and TString::tsv.

Referenced by f_luaopen().

Here is the call graph for this function:

Here is the caller graph for this function:

int luaX_lookahead ( LexState ls  ) 

Definition at line 511 of file llex.c.

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

Referenced by field().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 124 of file llex.c.

References LexState::fs, FuncState::h, LexState::L, luaC_checkGC, luaH_set(), luaS_newlstr(), setbvalue, setsvalue2s, lua_State::top, and ttisnil.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 156 of file llex.c.

References LexState::buff, LexState::current, LexState::decpoint, LexState::envn, LexState::fs, LexState::L, LexState::lastline, LexState::linenumber, LexState::lookahead, LUA_ENV, LUA_MINBUFFER, luaS_fix, luaS_new(), luaZ_resizebuffer, LexState::source, Token::token, and LexState::z.

Referenced by luaY_parser().

Here is the call graph for this function:

Here is the caller graph for this function:

l_noret luaX_syntaxerror ( LexState ls,
const char *  msg 
)

Definition at line 114 of file llex.c.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

const char* luaX_token2str ( LexState ls,
int  token 
)

Definition at line 75 of file llex.c.

References cast, FIRST_RESERVED, LexState::L, lisprint, lua_assert, LUA_QL, LUA_QS, luaO_pushfstring(), luaX_tokens, and TK_EOS.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 256 of file llex.c.

References LexState::buff, LexState::current, currIsNewline, EOZ, inclinenumber(), lexerror(), luaX_newstring(), luaZ_buffer, luaZ_bufflen, luaZ_resetbuffer, next, save(), save_and_next, skip_sep(), TK_EOS, and SemInfo::ts.

Referenced by llex().

Here is the call graph for this function:

Here is the caller graph for this function:

static void read_numeral ( LexState ls,
SemInfo seminfo 
) [static]

Definition at line 225 of file llex.c.

References LexState::buff, buff2d, buffreplace(), check_next(), LexState::current, LexState::decpoint, lisdigit, lislalnum, lua_assert, SemInfo::r, save(), save_and_next, and trydecpoint().

Referenced by llex().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 329 of file llex.c.

References LexState::buff, LexState::current, currIsNewline, EOZ, escerror(), inclinenumber(), lexerror(), lisdigit, lisspace, luaX_newstring(), luaZ_buffer, luaZ_bufflen, next, readdecesc(), readhexaesc(), save(), save_and_next, TK_EOS, TK_STRING, and SemInfo::ts.

Referenced by llex().

Here is the call graph for this function:

Here is the caller graph for this function:

static int readdecesc ( LexState ls  )  [static]

Definition at line 315 of file llex.c.

References LexState::current, escerror(), lisdigit, and next.

Referenced by read_string().

Here is the call graph for this function:

Here is the caller graph for this function:

static int readhexaesc ( LexState ls  )  [static]

Definition at line 301 of file llex.c.

References escerror(), lisxdigit, luaO_hexavalue(), and next.

Referenced by read_string().

Here is the call graph for this function:

Here is the caller graph for this function:

static void save ( LexState ls,
int  c 
) [static]
static int skip_sep ( LexState ls  )  [static]

Definition at line 243 of file llex.c.

References preferences::editor::TransitionUpdateMode::count, LexState::current, lua_assert, and save_and_next.

Referenced by llex(), and read_long_string().

Here is the caller graph for this function:

static void trydecpoint ( LexState ls,
SemInfo seminfo 
) [static]

Definition at line 212 of file llex.c.

References LexState::buff, buff2d, buffreplace(), LexState::decpoint, getlocaledecpoint, lexerror(), SemInfo::r, and TK_NUMBER.

Referenced by read_numeral().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 91 of file llex.c.

References LexState::buff, LexState::L, LUA_QS, luaO_pushfstring(), luaX_token2str(), luaZ_buffer, save(), TK_NAME, TK_NUMBER, and TK_STRING.

Referenced by lexerror().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

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>", "<name>", "<string>"
}

Definition at line 36 of file llex.c.

Referenced by luaX_init(), and luaX_token2str().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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