Mastermind is a programming language designed to compile to the esoteric language Brainfuck.
Brainfuck is essentially a modern interpretation of the classical Turing machine. It consists of a tape of 8-bit values, with simple increment/decrement, move left/right, and control flow operations. The full language only uses 8 control characters: +-><.,[].
Imagine if C was designed for computer architectures that run Brainfuck directly, that is what Mastermind is intended to be.
- Install Rust/Cargo and Node/NPM.
- Install Yarn:
npm i --global yarn. - Run
yarn. - Run
yarn build:wasm. - Run
yarn build:grammar. - Run
yarn dev, then follow the link to http://localhost:5173.
Commits to dev and main are published to https://staging.mastermind.lostpixels.org and https://mastermind.lostpixels.org respectively.
This repository contains two main components: the compiler and the web IDE. There are GitHub Actions workflows which build, test, and deploy the web IDE (with bundled compiler) to Firebase Web Hosting.
The ./compiler subdirectory contains a Cargo (Rust) package, ensure Rust is installed.
The compiler codebase has two main entrypoints: main.rs and lib.rs, for the command-line and WASM compilation targets respectively. All other Rust source files are common between compilation targets.
Key files to look at:
tokeniser.rs: tokenises the raw text files into Mastermind syntax tokens.parser.rs: parses strings of tokens into higher-level Mastermind clauses.compiler.rs: compiles the high-level clauses into a list of basic instructions akin to an intermediate representation (IR).builder.rs: takes the basic instructions from the compiler and builds the final Brainfuck program.
Some key commands:
(from within the ./compiler subdirectory)
cargo run -- -h: runs the command-line compiler module and displays command help informationcargo test: runs the automated test suitecargo build: builds the command-line modulewasm-pack build: builds the WASM module
The project root directory package.json/yarn.lock defines a Node package managed with Yarn. Most important commands or behaviours are defined as npm run or yarn scripts within package.json.
Ensure Node is installed, then ensure Yarn is installed with npm i --global yarn.
The web IDE is a SolidJS app using TypeScript/TSX, and Vite as a bundler. The text editing portions of the UI are provided by the codemirror plugin, and syntax highlighting is defined in the included lezer grammar: ./src/lexer/mastermind.grammar.
Some key commands:
yarn: installs npm packagesyarn build:wasm: builds the compiler WASM moduleyarn build:grammar: compiles the lezer grammar to JS for use in codemirroryarn dev: runs the SolidJS app in a local Vite dev serveryarn build: builds the SolidJS app