Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zegl/tre
LLVM backed progamming language (Go subset)
https://github.com/zegl/tre
clang golang language llvm llvm-ir programming-language
Last synced: 2 months ago
JSON representation
LLVM backed progamming language (Go subset)
- Host: GitHub
- URL: https://github.com/zegl/tre
- Owner: zegl
- License: mit
- Created: 2017-12-26T14:24:31.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-09-29T10:14:18.000Z (about 1 year ago)
- Last Synced: 2024-09-29T04:02:22.087Z (3 months ago)
- Topics: clang, golang, language, llvm, llvm-ir, programming-language
- Language: Go
- Homepage:
- Size: 495 KB
- Stars: 132
- Watchers: 5
- Forks: 15
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tre
> A LLVM backed Go compiler.
`tre` is built in Go and can compile a subset of Go code to LLVM IR. Clang is
used to compile the IR to an executable.## Building
```bash
# Build tre and run a test program
go build ./cmd/tre && ./tre -d ./compiler/testdata/fib.go && ./fib
```## Example
Example program that calculates the fibonacci sequence.
```go
func fib(num int) int {
if num < 2 {
return num
}return fib(num-2) + fib(num-1)
}func main() {
printf("%d\n", fib(34))
}
```More examples of what's possible can be found in the [compiler testdata](https://github.com/zegl/tre/tree/master/compiler/testdata).
## Features
### Types
- [x] int
- [x] string
- [x] struct
- [x] array
- [x] slice
- [ ] [map](https://github.com/zegl/tre/issues/34)
- [x] bool
- [x] func
- [ ] [chan](https://github.com/zegl/tre/issues/78)### Language features
- [ ] [first class func](https://github.com/zegl/tre/issues/36)
- [ ] packages
- [x] methods
- [x] pointers
- [x] interfaces
- [ ] [chan](https://github.com/zegl/tre/issues/78)
- [ ] [goroutines](https://github.com/zegl/tre/issues/77)
- [x] if/else if/else
- [ ] switch## Dependencies
* [clang](https://clang.llvm.org/) - Supports 8.0, 9.0, and 14
* [llir/llvm](https://github.com/llir/llvm)