Skip to main content

ParserHook

Type Alias ParserHook 

Source
pub type ParserHook = fn(state: &mut LuaState, z: &mut ZIO, name: &[u8], firstchar: i32) -> Result<GcRef<LuaLClosure>, LuaError>;
Expand description

Function-pointer signature for the text-source parser, installed on GlobalState::parser_hook by the embedder.

The implementation lives in lua-parse; lua-vm cannot depend on it directly (that would form a cycle), so the parser is reached via this function pointer registered at startup.

The parser receives the live ZIO (already positioned past firstchar) rather than a fully-materialised buffer, so it can pull reader chunks on demand and stop at the first syntax error — matching C’s lua_load, where the lexer drives the lua_Reader byte by byte.