{"id":13637304,"url":"https://github.com/rustq/3body-lang","last_synced_at":"2026-02-21T03:02:17.325Z","repository":{"id":65805248,"uuid":"599219428","full_name":"rustq/3body-lang","owner":"rustq","description":"三体编程语言 Three Body Language written in Rust","archived":false,"fork":false,"pushed_at":"2025-05-01T10:21:16.000Z","size":259,"stargazers_count":184,"open_issues_count":7,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-21T04:38:54.782Z","etag":null,"topics":["3bodyproblem","compiler","language","programming-language","rust","threebody","threebodyproblem"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rustq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["meloalright","rustq"]}},"created_at":"2023-02-08T17:41:45.000Z","updated_at":"2025-10-03T13:13:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"423848d8-9d1e-44f5-8298-c7044339c344","html_url":"https://github.com/rustq/3body-lang","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/rustq/3body-lang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustq%2F3body-lang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustq%2F3body-lang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustq%2F3body-lang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustq%2F3body-lang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustq","download_url":"https://codeload.github.com/rustq/3body-lang/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustq%2F3body-lang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29672258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T00:11:43.526Z","status":"online","status_checked_at":"2026-02-21T02:00:07.432Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3bodyproblem","compiler","language","programming-language","rust","threebody","threebodyproblem"],"created_at":"2024-08-02T00:01:14.913Z","updated_at":"2026-02-21T03:02:17.310Z","avatar_url":"https://github.com/rustq.png","language":"Rust","funding_links":["https://github.com/sponsors/meloalright","https://github.com/sponsors/rustq"],"categories":["Libraries"],"sub_categories":["Scripting"],"readme":"# 3body-lang\n\n[![License](https://img.shields.io/badge/license-MIT%20License-blue.svg)](https://opensource.org/licenses/MIT)\n[![Package version](https://img.shields.io/crates/v/three_body_lang.svg)](https://crates.io/crates/three_body_lang)\n[![Workflow](https://github.com/rustq/3body-lang/actions/workflows/CI.yml/badge.svg)](https://github.com/rustq/3body-lang/actions)\n[![HomeBrew](https://img.shields.io/homebrew/v/three-body\n)](https://formulae.brew.sh/formula/three-body)\n\n\n三体编程语言 Three Body Language written in Rust\n\n![carbon](https://user-images.githubusercontent.com/11075892/218237230-18000cfe-8db1-4bf7-979d-a11695039f35.png)\n\n目前三体编程语言已经实现了如 \"面壁\"、\"破壁\"、\"思想钢印\"、\"冬眠\" 等语法，不过仍然是一个概念级的编程语言。\n\n解释器的设计均来自于作者 Thorsten Ball 的原书，同时很感谢多个优秀开源仓库为本项目带来的灵感启发。\n\nAll from the book [Writing An Interpreter In Go](https://interpreterbook.com/)\n\nInspired by [wadackel/rs-monkey-lang](https://github.com/wadackel/rs-monkey-lang) + [flaneur2020/pua-lang](https://github.com/flaneur2020/pua-lang) which also inspired [Monkey-Rust-2021-Edition](https://github.com/meloalright/Monkey-Rust-2021-Edition)\n\n## ⚡️ Installation\n\n```shell\n$ brew install three-body\n```\n\n## ⚡️ Quick Start\n\n```shell\n$ 3body -h\n```\n\n```shell\n$ 3body\n```\n\n## Syntax Overview\n\n##### Variable bindings 变量绑定\n\n```shell\n给 \u003cidentifier\u003e 以 \u003cexpression\u003e;\n```\n\n`example:`\n\n```rust\n给 岁月 以 \"文明\";\n\n给 时光 以 \"生命\";\n```\n\n##### Constant bindings 常量绑定\n\n```shell\n思想钢印 \u003cidentifier\u003e = \u003cexpression\u003e;\n```\n\n`example:`\n\n```rust\n思想钢印 水 = \"剧毒的\";\n```\n\n##### 前进(+) 运算符\n\n```rust\n给 自然选择 以 0;\n\n自然选择 前进 4\n\n// \u003e 4\n```\n\n##### 降维(-) 运算符\n\n```rust\n给 宇宙 以 { \"维度\": 10 };\n\n宇宙.维度 降维 7\n\n// \u003e 3\n```\n\n##### Boolean 布尔值\n\n```rust\n这是计划的一部分\n\n// \u003e true\n```\n\n```rust\n主不在乎\n\n// \u003e false\n```\n\n##### Function 函数定义\n\n```shell\n法则 (\u003cparameter one\u003e, \u003cparameter two\u003e, ...) { \u003cblock statement\u003e };\n```\n\n`example:`\n\n```rust\n给 黑暗森林 以 法则() {\n    给 基本公理 以 [\"生存是文明的第一需要\", \"文明不断增长和扩张，但宇宙中的物质总量保持不变\"];\n    基本公理\n}\n\n黑暗森林()\n```\n\n##### Loop 循环语法\n\n```shell\n面壁 (\u003cexpression\u003e) { \u003cblock statement\u003e };\n```\n\n`example:`\n\n```rust\n给 危机纪年 以 3;\n给 面壁者 以 [\"泰勒\", \"雷迪亚兹\", \"希恩斯\", \"罗辑\"];\n\n面壁 (危机纪年 \u003c 400) {\n\n    危机纪年 = 危机纪年 + 1;\n\n    if (危机纪年 == 8) {\n        面壁者 = rest(面壁者);\n        延绪;\n    }\n    if (危机纪年 == 23) {\n        面壁者 = rest(面壁者);\n        延绪;\n    }\n    if (危机纪年 == 205) {\n        面壁者 = rest(面壁者);\n    }\n\n    if (危机纪年 == 205) {\n        破壁;\n    }\n}\n\n面壁者\n```\n\n## Built-in Functions\n\n##### Print\n\n```shell\n广播(\u003carg1\u003e, \u003carg2\u003e, ...): void\n```\n\n`example:`\n\n```rust\n给 三体世界坐标 以 \"半人马星系\";\n\n广播(三体世界坐标);\n\n// \u003e \"半人马星系\"\n```\n\n##### Sleep\n\n```shell\n冬眠(\u003carg1\u003e): void\n```\n\n`example:`\n\n```rust\n冬眠(1000);\n```\n\n##### Deep-Equal\n\n```shell\n没关系的都一样(\u003carg1\u003e, \u003carg2\u003e): bool\n```\n\n`example:`\n\n```rust\n没关系的都一样([1, [2, 3], { \"4\": 5 }], [1, [2, 3], { \"4\": 5 }]);\n\n// \u003e true\n```\n\n\n## Summary\n\n|Token|3body-lang|Explanation|\n|---|---|---|\n|let|给|\"give\"|\n|=|以|\"as\"|\n|const|思想钢印|\"thoughtcontrou\"|\n|+|前进|\"go forward\"|\n|-|降维|\"dimension reduction\"|\n|true|这是计划的一部分|\"It's part of the plan.\"|\n|false|主不在乎|\"The Lord doesn't care.\"|\n|fn|法则|\"rule\"|\n|while|面壁|\"face the wall\"|\n|break|破壁|\"break the wall\"|\n|continue|延绪|\"continue\"|\n|print|广播|\"broadcast\"|\n|sleep|冬眠|\"hibernation\"|\n|clear|二向箔清理|\"two-way foil cleaning\"|\n|exit|毁灭|\"destroy\"|\n|deep-equal|没关系的都一样|\"It's okay. It's all the same.\"|\n\n## 🧶 Threading\n\n三体编程语言可以通过 \"程心\" 创建并管理线程。\n\nAble to use threading to create and handle threads.\n\n#### Threads Create\n\n```rust\n给 cx 以 程心();\n\ncx.thread(星环公司, [\"掩体工程\", 0, 11])\ncx.thread(星环公司, [\"研制曲率飞船\", 5, 11])\n```\n\n#### Threads Await\n\n```rust\n给 cx 以 程心();\n\n给 秘密研究 以 cx.thread(星环公司, [\"重启光速飞船的研究\", 11, 66]);\ncx.join(秘密研究)\n```\n\n⚛️ Example threading of \"星环公司\" in [runs/14773757696](https://github.com/rustq/3body-lang/actions/runs/14773757696/job/41478235050)\n\n## Development\n\n```bash\n$ git clone https://github.com/rustq/3body-lang.git\n\n$ cd 3body-lang\n\n$ cargo run --features=\"repl\"\n```\n\n```\n$ cargo test -p three_body_interpreter\n```\n\n有更多建议和想法 💡\n\nCreate issues: [issues](https://github.com/rustq/3body-lang/issues)\n\n## Visual Studio Code Extension\n\n[3body-vscode-language-server](https://marketplace.visualstudio.com/items?itemName=meloalright.3body-vscode-language-server)\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustq%2F3body-lang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustq%2F3body-lang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustq%2F3body-lang/lists"}