My attempt at creating my own language. A strongly typed, functional, bytecode interpreter written in Rust. Based on the syntax and style of the languages I have liked using. Complete with a custom opinionated code formatter, linter, type-checker.
// Recursive Fibonacci
let fibonacci = n => match n
| ..2 -> 1
| n -> fibonacci(n - 1) + fibonacci(n - 2)
fibonacci(10)
A quick walkthrough of the language can be found here.
More examples can be found in the /examples folder.
Usage: bang.exe <COMMAND>
Commands:
run Runs a file
format Formats source files
lint Checks for lint warnings
typecheck Checks the file for type errors
print Prints debugging information
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
# To format the codebase:
cargo fmt
# To lint the codebase:
cargo clippy
# To run the tests:
cargo test
# To run the tests with Miri:
cargo miri test
# To build Bang:
cargo build --release
I have been inspired by/ used the following guides/ projects when creating Bang.
- Crafting Interpreters by Robert Nystrom
- A prettier printer by Philip Wadler
- Ruff
- Oxc Performance Guide
- Printing Trees in Rust
- Fault Tolerant Parsing from Chevrotain
I am no longer working on previous versions, but you can find them here:
- v2 (a slower Rust interpreter, with slightly different syntax)
- v1 (a tree walk interpreter in TypeScript)
The code in this repository is covered by the Apache License 2.0.