Skip to content
aashishaxoPublic

About

timepass

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Brainf

A Brainfuck compiler, built from scratch as a way to learn how compilers work.

Status: planning. No code yet. The full roadmap is in PLAN.md.

Brainfuck in one table

A byte tape (30,000 cells, all zero) and a pointer into it. Eight commands; everything else is a comment.

Cmd C equivalent
> ptr++;
< ptr--;
+ (*ptr)++;
- (*ptr)--;
. putchar(*ptr);
, *ptr = getchar();
[ while (*ptr) {
] }

Planned pipeline

source.bf → lexer → parser (IR) → optimizer → backend
                                               ├─ interpreter
                                               ├─ C source   (→ gcc/clang)
                                               └─ x86-64 asm (→ nasm → ld)

Roadmap

  1. Interpreter with a precomputed jump table
  2. Lexer and parser producing a flat IR
  3. Optimizer: run-length folding, clear/scan/copy loops, offset ops
  4. C backend
  5. Native x86-64 backend (NASM, Linux)
  6. Stretch: JIT, LLVM IR, WebAssembly

See PLAN.md for details and references.

About

timepass

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors