EvoX Genesis
EvoX Genesis turns a high-level software objective into a persistent recursive software world: finite-lived agents recursively develop software, while only accepted consequences persist across develop
翻譯準備中
尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
個人 GitHub 帳號下公開儲存庫的擁有者可以登入並驗證所有權,自行管理介紹,無需管理員核准。
登入並產生驗證檔案,在 30 分鐘內將其提交至此儲存庫的預設分支。其他分支或分叉儲存庫中的檔案無效。然後在下方檢查檔案,即可無需管理員核准直接管理專案。請保留檔案以維持管理權限。
如需登入,將前往登入頁面。登入後請回到此處,再次點擊所選的驗證按鈕。
在專案資料夾中執行 /nomorevibe verify,即可驗證所有權並自行管理介紹。
一分鐘完成驗證C to Lisp to Forth compiler. Built as a third-year university project.
翻譯準備中
取自儲存庫 README
正在載入完整 README。
檢視完整 README ↗
A C to Lisp to Forth compiler that runs in your browser
C to Forth is a two-stage compiler that turns C into Lisp and then Forth, running both in the browser and checking them against clisp, gforth and gcc
It was born as a third-year university project 🎓
flowchart TB
A["C Source"]:::nodeStyle1 --> B["Lexer"]:::nodeStyle2
B --> C["Parser"]:::nodeStyle2
C --> D["Lisp Emitter"]:::nodeStyle3
D --> E["Lisp Code"]:::nodeStyle4
E --> F["S-expression Reader"]:::nodeStyle3
F --> G["Forth Emitter"]:::nodeStyle3
G --> H["Forth Code"]:::nodeStyle4
E --> I["Lisp Interpreter"]:::nodeStyle5
H --> J["Forth Interpreter"]:::nodeStyle5
I --> K{"Same Output?"}:::decisionStyle
J --> K
classDef nodeStyle1 fill:#555555,color:#ffffff,stroke:#000000,stroke-width:2px,font-weight: bold;
classDef nodeStyle2 fill:#555555,color:#ffffff,stroke:#000000,stroke-width:2px,font-weight: bold;
classDef nodeStyle3 fill:#555555,color:#ffffff,stroke:#000000,stroke-width:2px,font-weight: bold;
classDef nodeStyle4 fill:#555555,color:#ffffff,stroke:#000000,stroke-width:2px,font-weight: bold;
classDef nodeStyle5 fill:#555555,color:#ffffff,stroke:#000000,stroke-width:2px,font-weight: bold;
classDef decisionStyle fill:#555555,color:#ffffff,stroke:#000000,stroke-width:2px,font-weight: bold;
c-to-forth/
├── .gitattributes # Git Attributes Configuration
├── .gitignore # Git Ignore Rules
├── biome.json # Lint & Format Configuration
├── index.html # Playground Page
├── LICENSE # Project License
├── package.json # Scripts & Dependencies
├── README.md # You are here! ⬅️
├── tsconfig.json # TypeScript Configuration
├── vite.config.ts # Build & Test Configuration
│
├── .github/workflows/
│ ├── ci.yml # Lint & Test Pipeline
│ └── pages.yml # GitHub Pages Deployment
│
├── assets/ # Visual Assets
│ ├── logo.svg # Project Logo
│ └── playground.png # Playground Screenshot
│
├── examples/ # Example C Programs
│
├── public/
│ └── favicon.svg # Playground Icon
│
├── src/
│ ├── compiler/
│ │ ├── lexer.ts # C Tokens
│ │ ├── parser.ts # C Syntax Tree
│ │ ├── lisp.ts # C to Lisp Translation
│ │ ├── sexpr.ts # S-expression Reader & Printer
│ │ ├── forth.ts # Lisp to Forth Translation
│ │ └── reserved.ts # Common Lisp & Gforth Names
│ │
│ ├── runtime/
│ │ ├── lisp.ts # Lisp Interpreter
│ │ └── forth.ts # Forth Interpreter
│ │
│ └── web/ # Playground Editor & Styles
│
└── tests/
├── expected/ # Verified Lisp, Forth & Outputs
├── fixtures/course/ # Original Course Test Programs
├── fixtures/lisp/ # Hand-Written Lisp Programs
├── fixtures/forth/ # Hand-Written Forth Programs
└── *.test.ts # Unit, Golden & Toolchain Tests
Clone the repository
git clone https://github.com/cristiangilsanz/c-to-forth.git
cd c-to-forth
Install the dependencies
npm install
npm run dev
npm test
npm run lint
sudo apt-get install clisp gforth gcc
dist/:npm run build
| C | Lisp | Forth |
|---|---|---|
int x = 5; | (setq x 5) | 5 value x |
int v[] = {1, 2, 3}; | (setq v (vector 1 2 3)) | create v 1 , 2 , 3 , |
x += v[i]; | (incf x (aref v i)) | x v i cells + @ + to x |
printf("%d\n", x); | (format t "~d~%" x) | x 0 .r cr |
if (a < b) ... else ... | (if (< a b) ... ...) | a b < if ... else ... then |
for (int i = 0; i < n; i++) | (dotimes (i n) ...) | n 0 max 0 ?do ... loop |
while (n > 0) ... | (loop while (> n 0) do ...) | begin n 0 > while ... repeat |
switch (d) { case 1: ... } | (case d (1 ...)) | d case 1 of ... endof endcase |
int f(int n) { ... } | (defun f (n) ...) | : f to f.n ... ; |
a / b and a % b | (truncate a b) and (rem a b) | a b quot and a b rem |
| Feature | Details |
|---|---|
| Types | int, char, short, long and bool as integers, arrays with initializers |
| Statements | if, else, while, do while, for, switch, break, continue and return |
| Operators | Arithmetic, comparisons, logic, bitwise, shifts, ?:, assignments, ++, -- and casts |
| Functions | Prototypes, recursion, mutual recursion and array parameters |
| Output | puts, putchar and printf with %d, %c, %s, %% and field widths |
| Extras | Hex, octal and character literals, # lines are skipped and //@ lines go into the Lisp |
| Stage | Details |
|---|---|
| Lisp Interpreter | Numbers, characters, strings, lists, vectors, closures, loop, format and special variables |
| Lisp to Forth | defun, let, cond, case, dotimes, loop with sum and count, block and vectors |
| Forth Interpreter | Colon definitions, do loops, case, defer, value, create, strings and number bases |
The following tips help you get the most out of C to Forth:
- Write a recursive function and see Forth save its locals.
- Edit the Lisp pane and watch the Forth follow.
- Share your code with Copy link.
This project was created together with Paola Herráez Bravo in our third year of university 🤝.
Thanks to the GNU CLISP and Gforth teams for the reference implementations every output is checked against ✨.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with 💖 for the Compiler Community