lua/llex.c File Reference

#include <ctype.h>
#include <string.h>
#include "lua.h"
#include "ldo.h"
#include "llex.h"
#include "lobject.h"
#include "lparser.h"
#include "lstate.h"
#include "lstring.h"
#include "lzio.h"

Go to the source code of this file.

Defines

#define llex_c
#define next(LS)   (LS->current = zgetc(LS->z))
#define MAXSRC   80
#define EXTRABUFF   32
#define MAXNOCHECK   5
#define checkbuffer(LS, len)
#define save(LS, c, l)   (luaZ_buffer((LS)->buff)[l++] = cast(char, c))
#define save_and_next(LS, l)   (save(LS, LS->current, l), next(LS))

Functions

void luaX_init (lua_State *L)
void luaX_checklimit (LexState *ls, int val, int limit, const char *msg)
void luaX_errorline (LexState *ls, const char *s, const char *token, int line)
static void luaX_error (LexState *ls, const char *s, const char *token)
void luaX_syntaxerror (LexState *ls, const char *msg)
const char * luaX_token2str (LexState *ls, int token)
static void luaX_lexerror (LexState *ls, const char *s, int token)
static void inclinenumber (LexState *LS)
void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source)
static size_t readname (LexState *LS)
static void read_numeral (LexState *LS, int comma, SemInfo *seminfo)
static void read_long_string (LexState *LS, SemInfo *seminfo)
static void read_string (LexState *LS, int del, SemInfo *seminfo)
int luaX_lex (LexState *LS, SemInfo *seminfo)

Variables

static const char *const token2string []


Define Documentation

#define checkbuffer ( LS,
len   ) 

Value:

if (((len)+MAXNOCHECK)*sizeof(char) > luaZ_sizebuffer((LS)->buff)) \
      luaZ_openspace((LS)->L, (LS)->buff, (len)+EXTRABUFF)

Definition at line 159 of file llex.c.

Referenced by read_long_string(), read_numeral(), read_string(), and readname().

#define EXTRABUFF   32

Definition at line 154 of file llex.c.

#define llex_c

Definition at line 11 of file llex.c.

#define MAXNOCHECK   5

Definition at line 157 of file llex.c.

#define MAXSRC   80

Definition at line 52 of file llex.c.

Referenced by luaX_errorline().

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

Definition at line 25 of file llex.c.

Referenced by addChangelog(), breakstat(), doReadRC(), forstat(), freeRpmVar(), Fts_read(), funcargs(), funcstat(), ifstat(), inclinenumber(), luaK_concat(), luaK_patchlistaux(), luaS_resize(), luaX_lex(), luaX_setinput(), luaY_field(), luaY_index(), luaY_parser(), parlist(), parseFormat(), prefixexp(), primaryexp(), read_string(), repeatstat(), retstat(), rpmalAdd(), rpmdbClose(), rpmdbFreeIterator(), rpmGetVarArch(), rpmReadPackageManifest(), rpmSetVarArch(), simpleexp(), statement(), str_checkname(), subexpr(), test_then_block(), testnext(), and whilestat().

#define save ( LS,
c,
 )     (luaZ_buffer((LS)->buff)[l++] = cast(char, c))

Definition at line 163 of file llex.c.

Referenced by read_long_string(), read_numeral(), read_string(), readname(), rpmdsMerge(), rpmfiDecideFate(), and rpmsqAction().

#define save_and_next ( LS,
 )     (save(LS, LS->current, l), next(LS))

Definition at line 165 of file llex.c.

Referenced by read_long_string(), read_numeral(), read_string(), and readname().


Function Documentation

static void inclinenumber ( LexState LS  )  [static]

Definition at line 117 of file llex.c.

References LexState::linenumber, luaX_checklimit(), MAX_INT, and next.

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

void luaX_checklimit ( LexState ls,
int  val,
int  limit,
const char *  msg 
)

Definition at line 55 of file llex.c.

References LexState::L, luaO_pushfstring(), and luaX_syntaxerror().

Referenced by code_params(), inclinenumber(), listfield(), new_localvar(), and recfield().

static void luaX_error ( LexState ls,
const char *  s,
const char *  token 
) [static]

Definition at line 72 of file llex.c.

References LexState::linenumber, and luaX_errorline().

Referenced by luaX_lex(), luaX_lexerror(), and luaX_syntaxerror().

void luaX_errorline ( LexState ls,
const char *  s,
const char *  token,
int  line 
)

Definition at line 63 of file llex.c.

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

Referenced by luaX_error(), and prefixexp().

void luaX_init ( lua_State L  ) 

Definition at line 41 of file llex.c.

References cast, lua_assert, luaS_fix, luaS_new, NUM_RESERVED, token2string, and TOKEN_LEN.

Referenced by f_luaopen().

int luaX_lex ( LexState LS,
SemInfo seminfo 
)

Definition at line 329 of file llex.c.

References LexState::buff, LexState::current, EOZ, FIRST_RESERVED, inclinenumber(), LexState::L, luaO_pushfstring(), luaS_newlstr(), luaX_error(), luaZ_buffer, next, read_long_string(), read_numeral(), read_string(), readname(), TString::reserved, TK_CONCAT, TK_DOTS, TK_EOS, TK_EQ, TK_GE, TK_LE, TK_NAME, TK_NE, TK_NUMBER, TK_STRING, SemInfo::ts, and TString::tsv.

Referenced by lookahead(), and next().

static void luaX_lexerror ( LexState ls,
const char *  s,
int  token 
) [static]

Definition at line 107 of file llex.c.

References luaX_error(), luaX_token2str(), luaZ_buffer, and TK_EOS.

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

void luaX_setinput ( lua_State L,
LexState LS,
ZIO z,
TString source 
)

Definition at line 126 of file llex.c.

References LexState::current, EOZ, LexState::fs, LexState::L, LexState::lastline, LexState::linenumber, LexState::lookahead, next, LexState::source, TK_EOS, Token::token, and LexState::z.

Referenced by luaY_parser().

void luaX_syntaxerror ( LexState ls,
const char *  msg 
)

Definition at line 79 of file llex.c.

References LexState::buff, getstr, luaX_error(), luaX_token2str(), luaZ_buffer, Token::seminfo, LexState::t, TK_NAME, TK_NUMBER, TK_STRING, Token::token, and SemInfo::ts.

Referenced by breakstat(), check_match(), error_expected(), forstat(), funcargs(), luaK_checkstack(), luaK_fixjump(), luaX_checklimit(), parlist(), prefixexp(), and whilestat().

const char* luaX_token2str ( LexState ls,
int  token 
)

Definition at line 97 of file llex.c.

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

Referenced by check_match(), error_expected(), luaX_lexerror(), and luaX_syntaxerror().

static void read_long_string ( LexState LS,
SemInfo seminfo 
) [static]

Definition at line 222 of file llex.c.

References checkbuffer, LexState::current, EOZ, inclinenumber(), luaX_lexerror(), save, save_and_next, and TK_EOS.

Referenced by luaX_lex().

static void read_numeral ( LexState LS,
int  comma,
SemInfo seminfo 
) [static]

Definition at line 183 of file llex.c.

References checkbuffer, luaO_str2d(), luaX_lexerror(), luaZ_buffer, SemInfo::r, save, save_and_next, and TK_NUMBER.

Referenced by luaX_lex().

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

Definition at line 271 of file llex.c.

References LexState::buff, checkbuffer, LexState::current, EOZ, inclinenumber(), LexState::L, luaS_newlstr(), luaX_lexerror(), luaZ_buffer, next, save, save_and_next, TK_EOS, TK_STRING, and SemInfo::ts.

Referenced by luaX_lex().

static size_t readname ( LexState LS  )  [static]

Definition at line 168 of file llex.c.

References checkbuffer, LexState::current, save, and save_and_next.

Referenced by luaX_lex().


Variable Documentation

const char* const token2string[] [static]

Initial value:

 {
    "and", "break", "do", "else", "elseif",
    "end", "false", "for", "function", "if",
    "in", "local", "nil", "not", "or", "repeat",
    "return", "then", "true", "until", "while", "*name",
    "..", "...", "==", ">=", "<=", "~=",
    "*number", "*string", "<eof>"
}

Definition at line 31 of file llex.c.

Referenced by luaX_init(), and luaX_token2str().


Generated on Fri Oct 12 08:44:55 2007 for rpm by  doxygen 1.5.2