pub struct LexState {Show 14 fields
pub current: i32,
pub linenumber: i32,
pub lastline: i32,
pub t: Token,
pub lookahead: Token,
pub fs: Option<()>,
pub z: ZIO,
pub buff: LexBuffer,
pub h: Option<GcRef<LuaTable>>,
pub long_str_anchor: HashMap<Vec<u8>, GcRef<LuaString>>,
pub dyd: Option<()>,
pub source: GcRef<LuaString>,
pub envn: GcRef<LuaString>,
pub version: LuaVersion,
}Expand description
Per-chunk lexer (and shared parser) state.
Corresponds to LexState in llex.h. Owns the input stream, token
buffer, and current/lookahead tokens.
§C mapping (types.tsv)
LexState.current → current: i32 (charint; -1 = EOZ)
LexState.linenumber → linenumber: i32
LexState.lastline → lastline: i32
LexState.t → t: Token (current token)
LexState.lookahead → lookahead: Token (one-token lookahead)
LexState.fs → fs: Option<Box<FuncState>> (parser state)
LexState.L → (removed; callers pass &mut LuaState)
LexState.z → z: ZIO (owned input stream)
LexState.buff → buff: LexBuffer (owned token-text buffer)
LexState.h → h: GcRef<LuaTable> (string-anchor table)
LexState.dyd → dyd: DynData (parser dynamic data)
LexState.source → source: GcRef<LuaString>
LexState.envn → envn: GcRef<LuaString>Fields§
§current: i32§linenumber: i32§lastline: i32§t: Token§lookahead: Token§fs: Option<()>§z: ZIO§buff: LexBuffer§h: Option<GcRef<LuaTable>>§long_str_anchor: HashMap<Vec<u8>, GcRef<LuaString>>Per-parse-session anchor for long strings. C-Lua’s ls->h is a Lua
table that deduplicates all literal strings within a chunk (both short
and long), so e.g. local s1 <const>="..." and local s2 <const>="..."
with identical 50-byte payloads share one TString object — which is
what makes string.format("%p", s1) == string.format("%p", s2) hold.
Short strings already share identity via the global interned_lt pool,
but long strings (>LUAI_MAXSHORTLEN = 40) are not globally interned and
need this session-level map. Keyed by the string bytes; populated lazily
by new_string.
dyd: Option<()>§source: GcRef<LuaString>§envn: GcRef<LuaString>§version: LuaVersionThe active Lua version, snapshotted at lexer setup from
state.global().lua_version (fixed for the lifetime of a parse). The
error formatters (lex_error/token2str) take only &LexState, so they
read the version here rather than threading a &LuaState through every
syntax-error callsite. Lua 5.1 quotes the special multi-char token labels
(<eof>, <name>, …) in error messages where 5.2+ leaves them bare.