Skip to main content

LexState

Struct LexState 

Source
pub struct LexState {
Show 13 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>,
}
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>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.