https://github.com/pickledchair/simplelang
The very simple language compiler written in Rust (from the book https://techbookfest.org/product/z9zCtNAJrigmuu3Jz9VDi?productVariantID=iMxgceXmQkk0T9d3cPskCP)
https://github.com/pickledchair/simplelang
Last synced: 8 months ago
JSON representation
The very simple language compiler written in Rust (from the book https://techbookfest.org/product/z9zCtNAJrigmuu3Jz9VDi?productVariantID=iMxgceXmQkk0T9d3cPskCP)
- Host: GitHub
- URL: https://github.com/pickledchair/simplelang
- Owner: PickledChair
- License: mit
- Created: 2023-11-17T06:33:56.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-17T07:31:35.000Z (over 2 years ago)
- Last Synced: 2025-01-18T16:22:06.927Z (over 1 year ago)
- Language: Rust
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simplelang
[cordx56](https://github.com/cordx56) 氏の「[Rustで作る!自作言語・コンパイラ入門](https://techbookfest.org/product/z9zCtNAJrigmuu3Jz9VDi?productVariantID=iMxgceXmQkk0T9d3cPskCP&utm_campaign=share&utm_medium=social&utm_source=twitter)」をもとに実装したシンプルな言語のコンパイラです。書籍では JIT コンパイルは LLVM で行っていますが、この実装では代わりに [Cranelift](https://cranelift.dev) を使用しました。
## 使い方
`cargo run` で REPL が起動します。代入文、if 文、print 文の3種類の入力を受け付けます。
以下は使用例です:
```
$ cargo run
Compiling simplelang v0.1.0 (/path/to/simplelang)
Finished dev [unoptimized + debuginfo] target(s) in 0.16s
Running `target/debug/simplelang`
If you want to quit, please enter `quit` or `exit`.
> a = 1
> b = 2
> print a + b
3
> print b - a
1
> if b - a == 1 then print 3
3
> exit
```