Welcome! This guide helps you navigate and understand the Mimo codebase efficiently. As an AI agent, you can leverage the CLI, REPL, and test suite to rapidly experiment and verify changes.
# 1. Test a quick expression
bun bin/cli.js -e "show + 1 2"
# 2. Run a file
echo 'show "Hello from Mimo"' > temp.mimo
bun bin/cli.js temp.mimo
# 3. Start REPL for interactive testing
bun repl.js
# 4. Run the test suite
bun test.js
# 5. Lint and format
bun bin/cli.js lint test/source/all.mimo
bun bin/cli.js fmt test/source/all.mimo --check# Workflow 1: Test a new feature
echo "your test code" | bun bin/cli.js
bun test.js # Ensure no regressions
# Workflow 2: Debug parser issues
bun bin/cli.js -e "your expression" 2>&1 | head -20
# Workflow 3: Test standard library changes
bun bin/cli.js -e "import math from 'math' \n show call math.sqrt 16"
# Workflow 4: Validate syntax changes
echo "function test() return 42 end" | bun bin/cli.jsMimo is a minimal, prefix-notation (Polish notation) programming language. It prioritizes simplicity, embeddability, and a consistent syntax where operators always precede their operands.
lexer/: ContainsLexer.js, responsible for tokenizing source code using regular expressions.parser/: ContainsParser.js, an LL(k) recursive descent parser that generates an Abstract Syntax Tree (AST).interpreter/: The core execution engine.Evaluator.js: A recursive tree-walker that evaluates AST nodes.environment.js: Manages variable storage and lexical scoping.Utils.js: Utility functions like truthiness check and stringification.
bin/: Containscli.js, the main entry point for CLI operations.repl.js: The interactive REPL implementation with multiline tracking and history.docs/: Public documentation, including the Syntax Guide.playground/: A SvelteKit-based web playground for Mimo.extensions/mimo-vscode/: VS Code extension providing syntax highlighting and execution support.tools/: Internal tools for formatting, linting, and REPL enhancements.adapters/: Bridging Mimo to host environments (e.g.,nodeAdapter.js).
Source Code
↓
┌─────────────┐
│ Lexer │ → Breaks source into tokens
└─────────────┘
↓
Tokens (array)
↓
┌─────────────┐
│ Parser │ → Builds Abstract Syntax Tree
└─────────────┘
↓
AST (tree structure)
↓
┌─────────────┐
│ Interpreter │ → Evaluates/executes AST
└─────────────┘
↓
Result
- Add token type →
lexer/TokenTypes.js - Add to lexer →
lexer/tokenizers/symbolTokenizer.js - Parse it →
parser/expressions/operatorExpressions.js - Evaluate it →
interpreter/evaluators/binaryExpressionEvaluator.js - Test it → Add to
test/source/all.mimo
- Define function →
interpreter/coreBuiltins.jsorinterpreter/stdlib/ - Export it → Add to exports in the module
- Test it →
bun bin/cli.js -e "show call your-function args"
- Add token →
lexer/TokenTypes.js - Parse it →
parser/statements/(new file or existing) - Execute it →
interpreter/executors/(new file or existing) - Update dispatcher →
interpreter/StatementExecutor.js
- Create module →
interpreter/stdlib/yourmodule.js - Export functions → Use
BuiltinFunctionwrapper - Register module → Add to module resolution in
ModuleLoader.js - Document it → Add tests in
test/source/and document indocs/.
As an AI agent, you can leverage the CLI for rapid experimentation and verification.
Use the --eval or -e flag to execute Mimo code without creating files:
# Basic evaluation
bun bin/cli.js -e "+ 1 2"
# Complex evaluation with built-ins
bun bin/cli.js -e "show call math.sqrt(16)"Redirect or pipe code into the CLI or REPL:
# Pipe code into CLI
echo "set x 10 \n show * x 2" | bun bin/cli.js
# Pipe code into REPL (automatically enables silent mode)
echo "function f(x) return * x 2 end \n show call f(10)" | bun repl.jsMimo uses a classic pipeline: Source -> Tokens -> AST.
- For grammar changes, start in
Lexer.jsfor new token types. - Update
Parser.jsto handle new statement or expression structures.
The Evaluator is the heart of Mimo. It iterates through AST nodes and performs actions based on node type.
- Binary Expressions: Handled in
Evaluator.jsusingnodeAdapterfor basic ops. - Function Calls: Scoping is handled by pushing/popping
Environmentinstances.
- Formatting:
bun bin/cli.js fmt <path> --write - Linting:
bun bin/cli.js lint <path> - Testing:
- Project tests:
bun test.js - REPL tests:
bun test/run_repl_tests.js - Language features:
test/source/contains various.mimofiles.
- Project tests:
to learn about testing, read the following files:
docs/testing.mdtest/README.md
A web-based interactive editor. it consist of two pages:
- landing page:
playground/src/routes/+page.svelte - playground page:
playground/src/routes/playground/+page.svelte
writen using sveltekit (svelte 5) and tailwindcss v4.
Provides syntax highlighting, snippets, and "Run" support.
- Packaging:
cd extensions/mimo-vscode && bun run package - Grammar:
syntaxes/mimo.tmLanguage.json
Refer to docs/syntax-guide.md for language reference. Happy coding!