An attempt at a Lua 5.1 implementation in Zig.
Goals, in order of priority:
- Learn more about Lua internals
- Learn more about Zig
- Anything else
- Lexer (llex.c/.h) -> lex.zig
- Keywords
- Identifiers
-
..,... -
==,>=,<=,~= - String literals (single/double quoted and multi-line (
[[)) - Comments (
--and--[[) - Numbers
- Improve tests, perhaps use fuzz testing
- Cleanup implementation
- String parsing (in Lua this was done at lex-time) -> parse_literal.zig (see
4324bd0for more details) - Number parsing (in Lua this was done at lex-time) -> parse_literal.zig
- Basic number parsing
- Proper
strtod-compatible number parsing implementation
- Parser (lparser.c/.h) (in Lua this was done as one step with no AST intermediate)
- Parsing tokens into an AST -> parse.zig (mostly done, needs some more testing/cleanup)
- Compiling the AST into bytecode -> compiler.zig
- ...
It's what I'm most familiar with, and I'm also assuming that 5.1 is simpler internally than more recent Lua versions.
zig buildto build zua.exezig build testto build & run the main test suitezig build runto build & run zua.exe (does nothing right now)zig build lua51_teststo run tests on the PUC Lua 5.1 test files (currently it just tests parsing them)zig build fuzzed_lexto run lexer tests on a large set of inputs/outputs generated by fuzzing-luazig build bench_lexto run a benchmark of the lexer (this benchmark needs improvement)zig build fuzzed_stringsto run string parsing tests on a set of inputs/outputs generated by fuzzing-lua