lua-lex 0.0.12

A Lua 5.4 interpreter implemented in safe Rust.
Documentation

Lexical analyzer — port of llex.c + llex.h.

Provides the Lua 5.4 lexer: character-by-character scanning of a [ZIO] input stream into [Token] values, with one-token lookahead. The llex.h header is merged here per PORTING.md §1.

C source files

  • reference/lua-5.4.7/src/llex.c (581 lines, 24 functions)
  • reference/lua-5.4.7/src/llex.h (91 lines; merged here)

Design notes

  • LexState.L (back-pointer to lua_State) is removed. All functions that need LuaState receive it as state: &mut LuaState.
  • Token.token is i32 in Phase A (matching the C int token field). Single-byte tokens are their ASCII values; reserved-word tokens start at FIRST_RESERVED (257). A proper TokenKind enum is deferred to Phase B.
  • save / save_and_next are now fallible (Result<(), LuaError>); the ? operator replaces the C noreturn lexerror call on buffer overflow.
  • The goto read_save / only_save / no_save pattern in read_string is translated via the local EscapeResult enum.