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.
Owns the input stream, token buffer, and current/lookahead tokens.
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, deduplicating all literal
strings within a chunk so e.g. local s1 <const>="..." and
local s2 <const>="..." with identical 50-byte payloads share one
LuaString 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 (>40 bytes) 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.