Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
llex.h File Reference
#include <limits.h>
#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   (UCHAR_MAX + 1)
 
#define LUA_ENV   "_ENV"
 
#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_GOTO , 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_IDIV , TK_CONCAT ,
  TK_DOTS , TK_EQ , TK_GE , TK_LE ,
  TK_NE , TK_SHL , TK_SHR , TK_DBCOLON ,
  TK_EOS , TK_FLT , TK_INT , TK_NAME ,
  TK_STRING
}
 

Functions

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

Macro Definition Documentation

◆ FIRST_RESERVED

#define FIRST_RESERVED   (UCHAR_MAX + 1)

Definition at line 20 of file lua-5.4.3/src/llex.h.

◆ LUA_ENV

#define LUA_ENV   "_ENV"

Definition at line 24 of file lua-5.4.3/src/llex.h.

◆ NUM_RESERVED

#define NUM_RESERVED   (cast_int(TK_WHILE-FIRST_RESERVED + 1))

Definition at line 46 of file lua-5.4.3/src/llex.h.

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_GOTO 
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_IDIV 
TK_CONCAT 
TK_DOTS 
TK_EQ 
TK_GE 
TK_LE 
TK_NE 
TK_SHL 
TK_SHR 
TK_DBCOLON 
TK_EOS 
TK_FLT 
TK_INT 
TK_NAME 
TK_STRING 

Definition at line 32 of file lua-5.4.3/src/llex.h.

32 {
33 /* terminal symbols denoted by reserved words */
38 /* other terminal symbols */
43};
#define FIRST_RESERVED
@ TK_FALSE
@ TK_STRING
@ TK_BREAK
@ TK_DBCOLON
@ TK_ELSE
@ TK_DOTS
@ TK_WHILE
@ TK_LOCAL
@ TK_TRUE
@ TK_THEN
@ TK_IDIV
@ TK_CONCAT
@ TK_NAME
@ TK_REPEAT
@ TK_FUNCTION
@ TK_UNTIL
@ TK_RETURN
@ TK_GOTO
@ TK_ELSEIF

Function Documentation

◆ luaX_init()

◆ luaX_lookahead()

LUAI_FUNC int 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

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

Referenced by constructor(), field(), field(), and field().

◆ 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 lua_State * L
struct FuncState * fs

References LexState::fs, FuncState::h, LexState::h, keyfromval, keystrval, LexState::L, luaC_checkGC, luaH_finishset(), luaH_getstr(), luaH_set(), luaH_setstr(), luaS_newlstr(), nodefromval, rawtsvalue, s2v, setbvalue, setsvalue, setsvalue2s, lua_State::top, tsvalue, and ttisnil.

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

◆ 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}

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

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

◆ luaX_setinput()

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

Definition at line 159 of file lua-5.2.4/src/llex.c.

160 {
161 ls->decpoint = '.';
162 ls->L = L;
163 ls->current = firstchar;
164 ls->lookahead.token = TK_EOS; /* no look-ahead token */
165 ls->z = z;
166 ls->fs = NULL;
167 ls->linenumber = 1;
168 ls->lastline = 1;
169 ls->source = source;
170 ls->envn = luaS_new(L, LUA_ENV); /* create env name */
171 luaS_fix(ls->envn); /* never collect this name */
172 luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */
173}
#define NULL
Definition gmacros.h:924
#define LUA_MINBUFFER
#define luaS_new(L, s)
#define luaS_fix(s)
#define luaZ_resizebuffer(L, buff, size)
#define LUA_ENV
TString * source
Mbuffer * buff
TString * envn

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, luaS_newliteral, luaZ_resizebuffer, NULL, LexState::source, LexState::t, TK_EOS, Token::token, and LexState::z.

◆ luaX_syntaxerror()

◆ 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 FIRST_RESERVED
#define cast(t, exp)
const char * luaO_pushfstring(lua_State *L, const char *fmt,...)

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

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