2 releases
new 0.1.0-alpha.1 | Mar 8, 2025 |
---|---|
0.1.0-alpha.0 | Jun 24, 2024 |
#67 in Programming languages
120KB
3K
SLoC
🌳 Terebinth
💭 About
The Terebinth programming language is a compiled language. The compiler is built entirely using Rust to ensure memory safety and robustness. For now, this is a hobby language that I wrote to learn more about how compilers work. I may iterate upon this to make it more robust in the future. I followed this tutorial to get everything set up initially, so check it out if you also want to create your own compiler!
📕 Documentation
The documentation for the latest version of the terebinth compiler can be found here. All previously published versions can be found on crates.io, and each version's respective documentation is accessible from there as well.
🔰 Getting Started
Installation
The Terebinth compiler can be installed using cargo:
cargo install terebinth
or it can be built and installed from source:
git clone git@github.com:crhowell3/terebinth.git
cd terebinth
cargo install --path .
Compiling Terebinth source code
Terebinth source files are suffixed with .ter
. The compiler will check that
source files provided to it have this extension; even if a file contains valid
Terebinth syntax, if it is not correctly suffixed, it will be rejected by the
compiler.
Here is an example of a simple Terebinth program:
// main.ter
func add(x: int, y: int) -> int {
return x + y
}
func main() {
let z = add(3, 5)
}
To compile, simply run terebinth main.ter
.
As of version 0.1.0-alpha.1
, no assembling or linking occurs, so a binary is not
generated. The compiler will tokenize, parse, and construct an AST that is then
evaluated. With the code above, you should see this output:
> terebinth main.ter
func add(x: int, y: int) -> int {
return x + y
}
func main() {
let z = add(3, 5)
}
Result: Some(8) <<<< Result here
Copyright © 2024-present Cameron Howell
Dependencies
~1.3–2MB
~39K SLoC