Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/squeek502/zua
An implementation of Lua 5.1 in Zig, for learning purposes
https://github.com/squeek502/zua
lua lua-vm zig
Last synced: about 2 months ago
JSON representation
An implementation of Lua 5.1 in Zig, for learning purposes
- Host: GitHub
- URL: https://github.com/squeek502/zua
- Owner: squeek502
- License: 0bsd
- Created: 2019-12-17T07:44:03.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-10T10:21:39.000Z (4 months ago)
- Last Synced: 2024-05-02T01:59:37.697Z (about 2 months ago)
- Topics: lua, lua-vm, zig
- Language: Zig
- Homepage:
- Size: 855 KB
- Stars: 149
- Watchers: 5
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-zig - squeek502/zua - An implementation of Lua 5.1 for learning purposes. (Compilers and interpreters)
- awesome-zig - zuaποΈAn implementation of Lua 5.1 in Zig, for learning purposes
- awesome-zig - squeek502/zua
- awesome-zig - squeek502/zua
README
Zua
===An attempt at a [Lua](https://lua.org) 5.1 implementation in [Zig](https://ziglang.org).
Goals, in order of priority:
1. Learn more about Lua internals
2. Learn more about Zig
3. Anything else## Status
- [ ] Lexer (llex.c/.h) -> [lex.zig](src/lex.zig)
+ [x] Keywords
+ [x] Identifiers
+ [x] `..`, `...`
+ [x] `==`, `>=`, `<=`, `~=`
+ [x] String literals (single/double quoted and multi-line (`[[`))
+ [x] Comments (`--` and `--[[`)
+ [x] Numbers
+ [x] Improve tests, perhaps use fuzz testing
- See [Fuzzing As a Test Case Generator](https://www.ryanliptak.com/blog/fuzzing-as-test-case-generator/) and [squeek502/fuzzing-lua](https://github.com/squeek502/fuzzing-lua/)
+ [ ] Cleanup implementation
- [x] String parsing (in Lua this was done at lex-time) -> [parse_literal.zig](src/parse_literal.zig) (see [`4324bd0`](https://github.com/squeek502/zua/commit/5de41fdf71eaf2a0b235e5eb581072d5488a1c57) for more details)
- [ ] Number parsing (in Lua this was done at lex-time) -> [parse_literal.zig](src/parse_literal.zig)
+ [x] 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)
+ [x] Parsing tokens into an AST -> [parse.zig](src/parse.zig) (mostly done, needs some more testing/cleanup)
+ [ ] Compiling the AST into bytecode -> [compiler.zig](src/compiler.zig)
- [ ] ...## Why Lua 5.1?
It's what I'm most familiar with, and I'm also assuming that 5.1 is simpler internally than more recent Lua versions.
## Building / running
- `zig build` to build zua.exe
- `zig build test` to build & run the main test suite
- `zig build run` to build & run zua.exe (does nothing right now)
- `zig build lua51_tests` to run tests on the PUC Lua 5.1 test files (currently it just tests parsing them)
- `zig build fuzzed_lex` to run lexer tests on a large set of inputs/outputs generated by [fuzzing-lua](https://github.com/squeek502/fuzzing-lua)
- `zig build bench_lex` to run a benchmark of the lexer (this benchmark needs improvement)
- `zig build fuzzed_strings` to run string parsing tests on a set of inputs/outputs generated by [fuzzing-lua](https://github.com/squeek502/fuzzing-lua)