pub struct LexState {Show 17 fields
pub current: i32,
pub linenumber: i32,
pub lastline: i32,
pub t: LexToken,
pub lookahead: LexToken,
pub fs: Option<Box<FuncState>>,
pub dyd: DynData,
pub source: Option<GcRef<LuaString>>,
pub envn: Option<GcRef<LuaString>>,
pub lex: LexState,
pub recursion_depth: u32,
pub global_strict: bool,
pub global_wildcard: bool,
pub global_wildcard_const: bool,
pub declared_globals: Vec<(GcRef<LuaString>, bool)>,
pub scope_barriers: Vec<ScopeBarrier>,
pub global_function_names: Vec<GcRef<LuaString>>,
}Expand description
PORT NOTE: This is a Phase A stub. In Phase B, LexState lives in
lua-lex and lua-parse imports it. FuncState will move here
or be passed separately. The fs field creates a circular-crate
dependency that Phase B must resolve (likely: both live in one crate).
Fields§
§current: i32§linenumber: i32§lastline: i32§t: LexToken§lookahead: LexToken§fs: Option<Box<FuncState>>§dyd: DynData§source: Option<GcRef<LuaString>>§envn: Option<GcRef<LuaString>>§lex: LexStateUnderlying lexer state that owns the ZIO stream and lex buffer.
The parser drives the lexer by calling lex_next / lex_lookahead,
which forward to lua_lex::next / lua_lex::lookahead on this inner
state and then mirror the resulting token into self.t / self.lookahead.
recursion_depth: u32Parser recursion depth for C-Lua’s enterlevel / leavelevel guard.
global_strict: boolLua 5.5 global-declaration mode (manual §2.2). A chunk begins with an
implicit global * (false here): every free name is a global, as in
5.4. The first explicit global name, … declaration flips this to
true (“strict”), after which a free name must appear in
Self::declared_globals or it is a compile-time error. global *
flips it back to false. Only ever set on the 5.5 path (the lexer emits
TK_GLOBAL only there), so pre-5.5 versions are unaffected.
global_wildcard: boolLua 5.5: whether a global * (the wildcard declaration) is in effect for
the current scope. When true, every free name is a global regardless of
Self::global_strict — the wildcard suppresses the “not declared”
error. Upstream represents * as a new_varkind(ls, NULL, ...) entry
that coexists with named global declarations; a later global name
does NOT void an active *. Block-scoped (saved/restored like
Self::declared_globals).
global_wildcard_const: boolWhether the active explicit global * wildcard was declared <const>.
Named global declarations still win for their own names; this applies
only to otherwise free globals resolved through the wildcard.
declared_globals: Vec<(GcRef<LuaString>, bool)>Names declared via global, each paired with whether it was declared
<const> (read-only). Consulted by name resolution under
Self::global_strict.
scope_barriers: Vec<ScopeBarrier>Lua 5.5 global declarations participate in goto scope checks like
locals, but they do not occupy VM registers. Keep that bookkeeping
separate from FuncState::nactvar so codegen remains register-stable.
global_function_names: Vec<GcRef<LuaString>>