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
Compile a subset of C into Lisp and then into Forth, and run both in your browser.
Developer toolsTypeScript · ForthGitHub @cristiangilsanzOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
C to Lisp to Forth compiler. Built as a third-year university project.
Translation pending
Taken from the repository README
Loading the full README.
Read the full 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