toy compiler targeting the bonsai lehrcomputer
- Rust 100%
| basm | it kinda works (we just use a lot more than 64 bytes) | |
| bcmp | it kinda works (we just use a lot more than 64 bytes) | |
| cli | it kinda works (we just use a lot more than 64 bytes) | |
| .gitignore | add gitignore | |
| Cargo.lock | prepare dependencies | |
| Cargo.toml | move stuff to cli and remove dbg prints from parser | |
| demo.bmc | update testfiles | |
| pda.txt | work on pda | |
| README.md | update grammar | |
| test.basm | update demo file format | |
| test.bmc | it kinda works (we just use a lot more than 64 bytes) | |
bmc
toy compiler for the bonsai lehrcomputer
learning resources
https://norasandler.com/2017/11/29/Write-a-Compiler.html
noch ein link: https://craftinginterpreters.com/parsing-expressions.html
und: https://craftinginterpreters.com/compiling-expressions.html
und: https://web.stanford.edu/class/cs143/lectures/lecture06.pdf
"porth" von alexey kutepov: https://gitlab.com/tsoding/porth
CFGs: https://iccl.inf.tu-dresden.de/w/images/6/6d/FS2025-Vorlesung-11-print.pdf
instructions
inc 00
dec 01
jmp 10
tst 11
sim: https://bonsai.inf-schule.de/assembler/
https://github.com/KlausMerkert/Bonsai
EBNF
https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form
frontend lang
letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
| "V" | "W" | "X" | "Y" | "Z" | "a" | "b"
| "c" | "d" | "e" | "f" | "g" | "h" | "i"
| "j" | "k" | "l" | "m" | "n" | "o" | "p"
| "q" | "r" | "s" | "t" | "u" | "v" | "w"
| "x" | "y" | "z" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
operator = "==" | "!=" ;
terminator = ";" ;
S = { " " | "\n" | "\t" } ;
identifier = { letter } ;
value = { digit } ;
expr = value | identifier ;
var = "let", S, identifier, S, "=", S, value, terminator ;
stmt = "(", expr, S, operator, S, expr, ")" ;
ifstmt = "if", S, stmt, S, block ;
block = "{", { var | ifstmt }, "}" ;
grammar = { block } ;
backend lang
letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
| "V" | "W" | "X" | "Y" | "Z" | "a" | "b"
| "c" | "d" | "e" | "f" | "g" | "h" | "i"
| "j" | "k" | "l" | "m" | "n" | "o" | "p"
| "q" | "r" | "s" | "t" | "u" | "v" | "w"
| "x" | "y" | "z" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
label = ":", { letter }, ":" ;
instruction = "inc" | "dec" | "jmp" | "tst" ;
line = [ label ] | [ instruction ], digit ;
grammar = { line } ;