How marflo-lang/m-language works
This repository implements the M language interpreter: a command-line user supplies a script, which is tokenized, parsed into syntax, compiled to IR and bytecode, then executed by the VM, with results displayed by the CLI. The runtime also includes value and collection objects, stack operations, VM utilities, and error handling. The CLI excerpt shows its frontend/compiler orchestration and result formatting; some later execution calls and internal runtime interactions are not shown, so those links are omitted or marked unverified.
Main entry points: cli.c CLI commands · vm.c Bytecode VM · err.c Diagnostics · mobjects.c Values and objects
Components 19
Command line
- CLI commands
src/cli/cli.c
Compilation backend
- IR compiler
src/backend/compiler.c - Bytecode generator
src/backend/codegen.c
Virtual machine
- Bytecode VM
src/vm/vm.c - Values and objects
src/vm/mobjects.c - VM stack API
src/vm/mstack.c - Value operations
src/vm/mvmutils.c - Runtime errors
src/vm/merror.c
Runtime support
- Arena allocator
src/utils/allocator.c - Diagnostics
src/utils/err.c - Value printing
src/utils/print.h - Common definitions
include/common.h - Language definitions
include/m.h - Runtime configuration
include/mconfig.h - Debug assertions
include/mdebug.h
Other components
- Script user
Connections 24
- Script user → CLI commands: provides script
src/cli/cli.c - CLI commands → Lexer: tokenizes source
src/cli/cli.c - CLI commands → Parser: parses tokens
src/cli/cli.c - CLI commands → IR compiler: compiles syntax
src/cli/cli.c - CLI commands → Bytecode generator: generates bytecode
src/cli/cli.c - CLI commands → VM stack API: formats result
src/cli/cli.c - Parser → AST types: builds syntax
- IR compiler → Bytecode generator: provides IR
- Bytecode generator → Bytecode VM: creates VM chunk
- Bytecode VM → Values and objects: operates on values
src/vm/vm.c - Bytecode VM → VM stack API: uses stack
src/vm/vm.c - Bytecode VM → Runtime errors: reports runtime faults
src/vm/merror.c - Bytecode VM → Diagnostics: reports diagnostics
src/utils/err.c - Values and objects → Debug assertions: uses assertions
src/vm/mobjects.c - VM stack API → Values and objects: manipulates values
src/vm/mstack.c - Bytecode VM → Value operations: uses value helpers
- Arena allocator → Diagnostics: reports allocation failures
src/utils/allocator.c - Lexer → Diagnostics: reports lexical errors
src/frontend/lexer.c - Parser → Diagnostics: reports syntax errors
src/frontend/parser.c - IR compiler → Diagnostics: reports compile errors
src/backend/compiler.c - CLI commands → Value printing: prints output
src/cli/cli.c - Debug assertions → Common definitions: uses definitions
include/mdebug.h - Values and objects → Runtime configuration: uses limits
- Language definitions → Runtime configuration: sets runtime types