How gearshift-interactive/cogwheel works
Cogwheel is a work-in-progress programming language implementation. Its principal workflow starts with a source-file argument, loads a module, finalizes it, compiles the resulting AST to bytecode, and runs that bytecode. The repository separates language front-end stages, semantic/type modeling, and runtime execution. The README documents language capabilities including functions, arrays, options, control flow, and stringification; these are represented by the compiler and VM rather than separate feature nodes. Sampled evidence shows main’s orchestration; internal module-loading and stage-to-stage calls are not fully visible, so those links are omitted.
Main entry points: main.c Program entry · bank.c Allocation bank · semantic_analyzer.c Semantic analysis · vm.c Virtual machine
Components 16
Language front end
- Module loading
src/module.c - Lexer
src/lexer.c - Parser
src/parser.c - AST model
src/node.c
Language semantics
- Semantic analysis
src/semantic_analyzer.c - Type system
src/type.c
Execution runtime
- Bytecode compiler
src/compiler.c - Virtual machine
src/vm.c - Runtime values
src/value.c - Value stack
src/stack.c - Global bindings
src/globals.h
Runtime support
- Allocation bank
src/bank.c - Diagnostics
src/error.c
Other components
- Source file user
- Program entry
src/main.c - Standard I/O
Connections 21
- Source file user → Program entry: provides source
src/main.c - Program entry → Module loading: loads and finalizes
src/main.c - Program entry → Bytecode compiler: compiles AST
src/main.c - Program entry → Virtual machine: runs bytecode
src/main.c - Program entry → Global bindings: builds bindings
src/main.c - Parser → AST model: produces AST
- Semantic analysis → AST model: analyzes AST
- Semantic analysis → Global bindings: checks bindings
- Type system → Lexer: uses tokens
- Virtual machine → Value stack: uses stack
src/vm.c - Virtual machine → Runtime values: executes values
- Program entry → Standard I/O: prints results
src/main.c - Lexer → Diagnostics: reports errors
src/lexer.c - Parser → Diagnostics: reports errors
src/parser.c - Semantic analysis → Diagnostics: reports errors
src/semantic_analyzer.c - Virtual machine → Diagnostics: reports errors
src/vm.c - Module loading → Allocation bank: allocates through
src/module.c - Lexer → Allocation bank: allocates through
src/lexer.c - Parser → Allocation bank: allocates through
src/parser.c - Semantic analysis → Allocation bank: allocates through
src/semantic_analyzer.c - Type system → Allocation bank: allocates through
src/type.c