Lua parser — translates the token stream produced by the lexer into
bytecode prototypes (LuaProto).
C source
reference/lua-5.4.7/src/lparser.c (1968 lines, 95 functions)
Design notes (Phase A)
BlockCntandLhsAssignform intrusive linked lists in C via raw pointers to stack-allocated nodes. In Rust they becomeOption<Box<...>>chains;enter_blockpushes,leave_blockpops.FuncState.prevsimilarly usesOption<Box<FuncState>>.FuncState.fisBox<LuaProto>during compilation (owned, mutably accessible). types.tsv maps it toGcRef<LuaProto>but interior- mutability viaRc<RefCell<...>>would be too noisy; Phase B can switch. PORT NOTE: FuncState.f is Box, not GcRef.LexStateis logically defined inlua-lex; a minimal stub is declared here for Phase A. Phase B will replace withlua_lex::LexStateonce inter-crate deps are wired.- Cross-crate calls to
lua_code::luaK_*andlua_lex::luaX_*are written as qualified paths and will resolve in Phase B. LuaStateis fromlua-vm; referenced here as an unresolved import.