Getting Started
Table of Contents
What You Need
- Zig 0.16+ — this is the only runtime requirement
- A terminal or shell
Your First Parser
The fastest path is to start with an example grammar that already ships with the repo. Run all commands from the repository root directory.
Parse existing JSON
sh
# 1. Generate the LL parser
zig build
./zig-out/bin/galley --parser-type ll languages/json
# 2. Build exactly that parser, then run it with release optimization
zig build -Doptimize=ReleaseFast ll-json
./zig-out/bin/ll-json languages/json/samples/code-01.jsonThat's it — languages/json/samples/code-01.json parses at hundreds of megabytes per second.
The separate json-recovery implementation demonstrates explicit recovery and custom messages while keeping the benchmark grammar minimal. Its demonstration input is intentionally malformed and exits with SyntaxError after reporting three recoverable value errors:
sh
./zig-out/bin/galley --parser-type ll --with-error-recovery languages/json-recovery
zig build ll-json-recovery
./zig-out/bin/ll-json-recovery languages/json-recovery/recovery-demo.jsonTry the LR parser too
sh
# 1. Generate the LR parser
zig build
./zig-out/bin/galley --parser-type lr languages/json
# 2. Build and run it
zig build -Doptimize=ReleaseFast lr-json
./zig-out/bin/lr-json languages/json/samples/code-01.jsonNext Steps
Now that you have verified the bundled JSON parsers work, you can learn how to use Galley from another Zig project, explore the other included languages, check out the CLI configuration and flags, or start writing your own custom language.