lua-parse 0.0.14

A Lua 5.4 interpreter implemented in safe Rust.
Documentation

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)

  • BlockCnt and LhsAssign form intrusive linked lists in C via raw pointers to stack-allocated nodes. In Rust they become Option<Box<...>> chains; enter_block pushes, leave_block pops.
  • FuncState.prev similarly uses Option<Box<FuncState>>.
  • FuncState.f is Box<LuaProto> during compilation (owned, mutably accessible). types.tsv maps it to GcRef<LuaProto> but interior- mutability via Rc<RefCell<...>> would be too noisy; Phase B can switch. PORT NOTE: FuncState.f is Box, not GcRef.
  • LexState is logically defined in lua-lex; a minimal stub is declared here for Phase A. Phase B will replace with lua_lex::LexState once inter-crate deps are wired.
  • Cross-crate calls to lua_code::luaK_* and lua_lex::luaX_* are written as qualified paths and will resolve in Phase B.
  • LuaState is from lua-vm; referenced here as an unresolved import.