How vladk1m0/gbfm works
Project type and purpose
• This is a command-line Brainfuck “machine” (an interpreter + transpiler) written in Go.
• Purpose: take a .bf source file, parse it, then either execute it directly or generate equivalent JavaScript code for later execution.
File structure
• Top level:
• main.go → entry point; dispatches “run” vs “translate” modes
• gbfm.sh → thin shell wrapper around the Go binary
• go.mod → module definition
• test_data/ → sample .bf programs
• brainfuck/ → core package
• parser.go → reads raw tokens, builds AST or instruction list
• interpreter.go → executes instructions against a data tape (stack)
• transpiler.go → walks instructions/AST, produces target code
• target.go → definitions for code‐generation hooks, target interfaces
• stack/ → runtime tape (data memory) abstraction
• Tests everywhere to validate parser, stack, interpreter, and transpiler
• Patterns:
• Classic compiler pipeline: front-end (lexer/parser), intermediate in-memory representation, two back-ends (interpreter engine + transpiler back-end).
• Clear separation of concerns by package.
README for additional insights
• Only JavaScript is supported as a transpilation target.
• The shell script hides Go build & mode flags.
• External dependency: Node.js to run generated .bf.js.