A Brainfuck interpreter, written as an opportunity to practice TDD.
- The source code goes through a lexer that produces a series of tokens
- These tokens are parsed into an abstract syntax tree (AST)
- The AST is visited (depth-first) and interpreted by the runtime
While this seems overkill, the goal of this project is to familiarize with compiler concepts, hence the apprent complexity for such a simple problem.
- Refactor to a LR parser based on a defined grammar
- Optimization (constant folding, run-length encoding, replace idioms...)
- Add visitor support to transpile code
- Better syntax error handling
- Comment support
Brainfuck's Backus-Naur form could be:
- <prg> ::= <expr> | <expr> <prg>
- <expr> ::=
+|-|<|>|.|,| <loop> - <loop> ::=
[+ <expr> +]