Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
llex.h File Reference
#include "lobject.h"
#include "lzio.h"

Go to the source code of this file.

Data Structures

union  SemInfo
 
struct  Token
 
struct  LexState
 

Macros

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

Typedefs

typedef struct Token Token
 
typedef struct LexState LexState
 

Enumerations

enum  RESERVED {
  TK_AND = FIRST_RESERVED , 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

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

Variables

LUAI_DATA const char *const luaX_tokens []
 

Macro Definition Documentation

◆ FIRST_RESERVED

#define FIRST_RESERVED   257

Definition at line 14 of file lua-5.1.5/src/llex.h.

Referenced by llex(), llex(), llex(), llex(), and luaX_token2str().

◆ NUM_RESERVED

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

Definition at line 36 of file lua-5.1.5/src/llex.h.

Referenced by luaX_init().

◆ TOKEN_LEN

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

Definition at line 17 of file lua-5.1.5/src/llex.h.

Referenced by luaX_init().

Typedef Documentation

◆ LexState

typedef struct LexState LexState

◆ Token

typedef struct Token Token

Enumeration Type Documentation

◆ RESERVED

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 lua-5.1.5/src/llex.h.

24 {
25 /* terminal symbols denoted by reserved words */
30 /* other terminal symbols */
33};
#define FIRST_RESERVED
@ TK_FALSE
@ TK_NUMBER
@ TK_STRING
@ TK_BREAK
@ TK_ELSE
@ TK_DOTS
@ TK_WHILE
@ TK_LOCAL
@ TK_TRUE
@ TK_THEN
@ TK_CONCAT
@ TK_NAME
@ TK_REPEAT
@ TK_FUNCTION
@ TK_UNTIL
@ TK_RETURN
@ TK_ELSEIF

Function Documentation

◆ luaX_init()

LUAI_FUNC void luaX_init ( lua_State * L)

Definition at line 21 of file noparser.c.

21 {
22 UNUSED(L);
23}
#define UNUSED(x)

◆ luaX_lexerror()

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

Definition at line 102 of file lua-5.1.5/src/llex.c.

102 {
103 char buff[MAXSRC];
104 luaO_chunkid(buff, getstr(ls->source), MAXSRC);
105 msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
106 if (token)
107 luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token));
109}
void luaD_throw(lua_State *L, int errcode)
#define MAXSRC
static const char * txtToken(LexState *ls, int token)
void luaO_chunkid(char *out, const char *source, size_t bufflen)
const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
#define getstr(ts)
#define LUA_ERRSYNTAX
#define LUA_QS
struct lua_State * L
TString * source

References getstr, LexState::L, LexState::linenumber, LUA_ERRSYNTAX, LUA_QS, 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().

◆ luaX_lookahead()

LUAI_FUNC void luaX_lookahead ( LexState * ls)

Definition at line 459 of file lua-5.1.5/src/llex.c.

459 {
461 ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
462}
static int llex(LexState *ls, SemInfo *seminfo)
#define lua_assert(c)
SemInfo seminfo

◆ luaX_newstring()

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

Definition at line 117 of file lua-5.1.5/src/llex.c.

117 {
118 lua_State *L = ls->L;
119 TString *ts = luaS_newlstr(L, str, l);
120 TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */
121 if (ttisnil(o)) {
122 setbvalue(o, 1); /* make sure `str' will not be collected */
123 luaC_checkGC(L);
124 }
125 return ts;
126}
#define luaC_checkGC(L)
#define setbvalue(obj, x)
#define ttisnil(o)
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
TValue * luaH_setstr(lua_State *L, Table *t, TString *key)
struct FuncState * fs

◆ luaX_next()

LUAI_FUNC void luaX_next ( LexState * ls)

Definition at line 448 of file lua-5.1.5/src/llex.c.

448 {
449 ls->lastline = ls->linenumber;
450 if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */
451 ls->t = ls->lookahead; /* use this one */
452 ls->lookahead.token = TK_EOS; /* and discharge it */
453 }
454 else
455 ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */
456}

◆ luaX_setinput()

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

Definition at line 140 of file lua-5.1.5/src/llex.c.

140 {
141 ls->decpoint = '.';
142 ls->L = L;
143 ls->lookahead.token = TK_EOS; /* no look-ahead token */
144 ls->z = z;
145 ls->fs = NULL;
146 ls->linenumber = 1;
147 ls->lastline = 1;
148 ls->source = source;
149 luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */
150 next(ls); /* read first char */
151}
#define NULL
Definition gmacros.h:924
#define next(ls)
#define LUA_MINBUFFER
#define luaZ_resizebuffer(L, buff, size)
Mbuffer * buff

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

Referenced by luaY_parser(), and luaY_parser().

◆ luaX_syntaxerror()

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

Definition at line 112 of file lua-5.1.5/src/llex.c.

112 {
113 luaX_lexerror(ls, msg, ls->t.token);
114}
void luaX_lexerror(LexState *ls, const char *msg, int token)

◆ luaX_token2str()

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

Definition at line 78 of file lua-5.1.5/src/llex.c.

78 {
79 if (token < FIRST_RESERVED) {
80 lua_assert(token == cast(unsigned char, token));
81 return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) :
82 luaO_pushfstring(ls->L, "%c", token);
83 }
84 else
85 return luaX_tokens[token-FIRST_RESERVED];
86}
const char *const luaX_tokens[]
#define cast(t, exp)

Variable Documentation

◆ luaX_tokens

LUAI_DATA const char* const luaX_tokens[]

Definition at line 40 of file lua-5.1.5/src/llex.h.