ProductPromotion
Logo

Rust

made by https://0x3d.site

GitHub - rustq/3body-lang: 三体编程语言 Three Body Language written in Rust
三体编程语言 Three Body Language written in Rust. Contribute to rustq/3body-lang development by creating an account on GitHub.
Visit Site

GitHub - rustq/3body-lang: 三体编程语言 Three Body Language written in Rust

GitHub - rustq/3body-lang: 三体编程语言 Three Body Language written in Rust

3body-lang

License Package version Workflow HomeBrew

三体编程语言 Three Body Language written in Rust

carbon

目前三体编程语言已经实现了如 "面壁"、"破壁"、"思想钢印"、"冬眠" 等语法,不过仍然是一个概念级的编程语言。

解释器的设计均来自于作者 Thorsten Ball 的原书,同时很感谢多个优秀开源仓库为本项目带来的灵感启发。

All from the book Writing An Interpreter In Go

Inspired by wadackel/rs-monkey-lang + flaneur2020/pua-lang which also inspired Monkey-Rust-2021-Edition

⚡️ Installation

$ brew install three-body

⚡️ Quick Start

$ 3body -h
$ 3body

Syntax Overview

Variable bindings 变量绑定
给 <identifier> 以 <expression>;

example:

给 岁月 以 "文明";

给 时光 以 "生命";
Constant bindings 常量绑定
思想钢印 <identifier> = <expression>;

example:

思想钢印 水 = "剧毒的";
前进(+) 运算符
给 自然选择 以 0;

自然选择 前进 4

// > 4
降维(-) 运算符
给 宇宙 以 { "维度": 10 };

宇宙.维度 降维 7

// > 3
Boolean 布尔值
这是计划的一部分

// > true
主不在乎

// > false
Function 函数定义
法则 (<parameter one>, <parameter two>, ...) { <block statement> };

example:

给 黑暗森林 以 法则() {
    给 基本公理 以 ["生存是文明的第一需要", "文明不断增长和扩张,但宇宙中的物质总量保持不变"];
    基本公理
}

黑暗森林()
Loop 循环语法
面壁 (<expression>) { <block statement> };

example:

给 危机纪年 以 3;
给 面壁者 以 ["泰勒", "雷迪亚兹", "希恩斯", "罗辑"];

面壁 (危机纪年 < 400) {

    危机纪年 = 危机纪年 + 1;

    if (危机纪年 == 8) {
        面壁者 = rest(面壁者);
        延绪;
    }
    if (危机纪年 == 23) {
        面壁者 = rest(面壁者);
        延绪;
    }
    if (危机纪年 == 205) {
        面壁者 = rest(面壁者);
    }

    if (危机纪年 == 205) {
        破壁;
    }
}

面壁者

Built-in Functions

Print
广播(<arg1>, <arg2>, ...): void

example:

给 三体世界坐标 以 "半人马星系";

广播(三体世界坐标);

// > "半人马星系"
Sleep
冬眠(<arg1>): void

example:

冬眠(1000);
Deep-Equal
没关系的都一样(<arg1>, <arg2>): bool

example:

没关系的都一样([1, [2, 3], { "4": 5 }], [1, [2, 3], { "4": 5 }]);

// > true

Summary

Token 3body-lang Explanation
let "give"
= "as"
const 思想钢印 "thoughtcontrou"
+ 前进 "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"
print 广播 "broadcast"
sleep 冬眠 "hibernation"
clear 二向箔清理 "two-way foil cleaning"
exit 毁灭 "destroy"
deep-equal 没关系的都一样 "It's okay. It's all the same."

🧶 Threading

三体编程语言可以通过 "程心" 创建并管理线程。

Able to use threading to create and handle threads.

Threads Create

给 cx 以 程心();

cx.thread(星环公司, ["掩体工程", 0, 11])
cx.thread(星环公司, ["研制曲率飞船", 5, 11])

Threads Await

给 cx 以 程心();

给 秘密研究 以 cx.thread(星环公司, ["重启光速飞船的研究", 11, 66]);
cx.join(秘密研究)

⚛️ Example threading of "星环公司" in runs/11302243115

🤗 LLM

三体编程语言可以通过 "智子工程" 加载本地大语言模型进行推理。

Able to use three body language sophon to load a local large language model for reasoning, inspired by wiki/sophon and powered by rustformers/llm.

sophon

Sophon Initializing

智子工程({ "type": <string>, "path": <string>, "prompt": <string> })
property type Explanation
type string 模型类型
path string 模型所在路径
prompt string 提示词

Reasoning

let 智子 = fn () { let instance = 智子工程({ "type": "llama", "path": "./Vicuna-13B-chinese.bin", "prompt": "你是三体文明的智子" }); return { "回答": fn (问题) { instance.infer(instance, 问题) } } }();

智子.回答("中国最佳科幻小说是哪个")

// > 推理中...
property type Explanation
model NativeObject::LLMModel 模型
character string 提示词角色
infer BuiltinFunc 执行推理
close BuiltinFunc 关闭会话

sophon workflow

⚛️ Example reasoning of "中国最佳科幻小说是哪个" in runs/11092893924

Model powered by huantian2415/vicuna-13b-chinese-4bit-ggml

Development

$ git clone https://github.com/rustq/3body-lang.git

$ cd 3body-lang

$ cargo run --features="repl"
$ cargo test -p three_body_interpreter

有更多建议和想法 💡

Create issues: issues

Visual Studio Code Extension

3body-vscode-language-server

License

MIT

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory