3body-lang
三体编程语言 Three Body Language written in Rust
Playground: https://rustq.github.io/3body-lang/
Base on Writing An Interpreter In Go and monkey-lang
Try 3body-lang
With REPL

With Runtime

With Online Playground

Working with Wasm!! 主很在乎 👏🏻
Playground: https://rustq.github.io/3body-lang/
Syntax overview
Variable bindings
Format
给 <identifier> 以 <expression>;
Example
给 岁月 以 "文明";
给 时光 以 "生命";
Operators
前进(+)运算符
给 自然选择 以 0;
自然选择 前进 4
// > 4
降维(-)运算符
给 宇宙 以 ;
宇宙 降维 7
// > 3
Boolean
这是计划的一部分
// > true
主不在乎
// > false
Function
Format
法则 (<parameter one>, <parameter two>, ...) { <block statement> };
Example
给 黑暗森林 以 法则
黑暗森林
Loop
Format
面壁 (<expression>) { <block statement> };
Example
给 面壁计划 以 法则
面壁计划
Built-in Functions
Format
广播(<arg1>, <arg2>, ...): void
Example
给 三体世界坐标 以 "半人马星系";
广播;
// > "半人马星系"
Sleep
Format
冬眠(<arg1>): void
Example
冬眠;
Clear
Format
二向箔清理(): void
Example
二向箔清理;
Exit
Format
毁灭(): void
Example
毁灭;
Summary
| Monkey | 3body-lang | Explanation |
|---|---|---|
| let | 给 | "give" |
| = | 以 | "as" |
| + | 前进 | "go forward" |
| - | 降维 | "dimension reduction" |
| true | 这是计划的一部分 | "It's part of the plan." |
| false | 主不在乎 | "The Lord doesn't care." |
| fn | 法则 | "rule" |
| while | 面壁 | "face the wall" |
| break | 破壁 | "break the wall" |
| continue | 延续、延绪 | "continue" |
| 广播 | "broadcast" | |
| sleep | 冬眠 | "hibernation" |
| clear | 二向箔清理 | "two-way foil cleaning" |
| exit | 毁灭 | "destroy" |
System Libraries
Development
$ ./target/debug/runtime ./example/macroatom.3body
$ make build_wasm
$ make test
有更多建议和想法 💡
Create issues: issues