Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ikskuh/parser-toolkit
A toolkit that makes it easier to write recursive-descent parsers in Zig.
https://github.com/ikskuh/parser-toolkit
compiler compiler-frontend parser recursive-descent-parser tokenizer tokenizer-parser zig zig-package ziglang
Last synced: 6 days ago
JSON representation
A toolkit that makes it easier to write recursive-descent parsers in Zig.
- Host: GitHub
- URL: https://github.com/ikskuh/parser-toolkit
- Owner: ikskuh
- License: mit
- Created: 2021-08-19T09:09:46.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-30T06:22:40.000Z (4 months ago)
- Last Synced: 2024-12-24T09:07:46.609Z (14 days ago)
- Topics: compiler, compiler-frontend, parser, recursive-descent-parser, tokenizer, tokenizer-parser, zig, zig-package, ziglang
- Language: Zig
- Homepage:
- Size: 1.09 MB
- Stars: 73
- Watchers: 4
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A parser toolkit
![Project Logo](design/logo.png)
This repo contains a tiny parser toolkit that can be used to build new parsers and programming languages.
It provides:
- [x] Configurable tokenizer
- [x] Parser core (accept functions with state restoration)
- [ ] Compiler error management (emission, rendering, source locations)## Demo
Invoke `zig build run` to run a tiny command line calculator that can evaluate basic expressions, parens and invoke functions:
```
$ zig build run
? 10
= 10
? 10 + 10
= 20
? 5 * 3
= 15
? a = 10
= 10
? sqrt(a)
= 3.1622776601683795
? sin(3.14)
= 0.0015926529164868282
? a = a + 1
= 11
? a = a + 1
= 12
? ^D
```Available functions are:
```zig
fn sin(v: f64) f64
fn cos(v: f64) f64
fn tan(v: f64) f64
fn sqrt(v: f64) f64
fn pow(a: f64, b: f64) f64
fn ln(v: f64) f64
fn ln10(v: f64) f64
fn ln2(v: f64) f64
fn log(b: f64, v: f64) f64
```