How alve-dev/zonetic-compiler works
Zonetic is a statically typed, expression-oriented language compiler with CLI tooling and a bytecode backend. The main workflow is source input through lexing, normalization, parsing into an AST, semantic/type analysis, optimization, and bytecode emission for the external ZonVM. The graph also shows the compiler’s symbol/type layer and shared diagnostics. The README documents REPL and legacy-interpreter modes, but this source tree does not expose a separate interpreter or VM implementation; the CLI excerpt shows REPL input being sent through compilation.
Main entry points: cmd_zonc.py CLI Commands · parser.py Parser · engine.py Diagnostic Engine · enviroment.py Symbols and Scopes
Components 21
CLI Interface
- CLI Commands
src/zonc/cli/cmd_zonc.py
Front End
- Lexer
src/zonc/scanner/lexer.py - Normalizer
src/zonc/syntatic_normalizer/the_normalizer.py - Parser
src/zonc/parser/parser.py - AST
src/zonc/zonast/program.py
Analysis
- Semantic Analysis
src/zonc/semantic/semantic.py - Type Inference
src/zonc/semantic/type_inference.py - Symbols and Scopes
src/zonc/enviroment/enviroment.py - AST Optimizations
src/zonc/optimization/constant_folding.py - Dead-Code Elimination
src/zonc/optimization/dead_code_elimination.py
Bytecode Backend
- Bytecode Emitter
src/zonc/bytecodegen/emitter.py - Expression Generation
src/zonc/bytecodegen/expr_gen.py - Statement Generation
src/zonc/bytecodegen/stmt_gen.py - Bytecode Scope
src/zonc/bytecodegen/bytecodescope.py - Register Allocation
src/zonc/bytecodegen/linear_scan_register_allocation.py - Instructions and Data
src/zonc/bytecodegen/instruction.py
Compiler Support
- Diagnostic Engine
src/zonc/zonc_errors/engine.py - Diagnostic Renderer
src/zonc/zonc_errors/renderer.py - Source Spans
src/zonc/location_file/span.py
Other components
- Programmer
- ZonVM
Connections 30
- Programmer → CLI Commands: submits code
- CLI Commands → Lexer: scans source
src/zonc/cli/cmd_zonc.py - Lexer → Normalizer: tokens to
- Normalizer → Parser: tokens to
- Parser → AST: builds
src/zonc/parser/parser.py - Parser → Symbols and Scopes: uses scopes
src/zonc/parser/parser.py - Parser → Diagnostic Engine: emits errors
src/zonc/parser/parser.py - CLI Commands → Parser: parses tokens
src/zonc/cli/cmd_zonc.py - CLI Commands → Semantic Analysis: checks AST
src/zonc/cli/cmd_zonc.py - Semantic Analysis → Type Inference: inherits inference
src/zonc/semantic/semantic.py - Semantic Analysis → Symbols and Scopes: checks bindings
src/zonc/semantic/semantic.py - Type Inference → Symbols and Scopes: looks up names
src/zonc/semantic/type_inference.py - Semantic Analysis → Diagnostic Engine: emits errors
src/zonc/semantic/semantic.py - CLI Commands → AST Optimizations: folds constants
src/zonc/cli/cmd_zonc.py - CLI Commands → Dead-Code Elimination: eliminates dead code
src/zonc/cli/cmd_zonc.py - AST Optimizations → Symbols and Scopes: uses environment
src/zonc/optimization/constant_folding.py - Dead-Code Elimination → Symbols and Scopes: uses environment
src/zonc/optimization/dead_code_elimination.py - CLI Commands → Bytecode Emitter: emits bytecode
src/zonc/cli/cmd_zonc.py - Bytecode Emitter → Statement Generation: generates statements
- Statement Generation → Expression Generation: generates expressions
src/zonc/bytecodegen/stmt_gen.py - Expression Generation → Bytecode Scope: uses scope
src/zonc/bytecodegen/expr_gen.py - Statement Generation → Bytecode Scope: uses scope
src/zonc/bytecodegen/stmt_gen.py - Expression Generation → Instructions and Data: builds instructions
src/zonc/bytecodegen/expr_gen.py - Statement Generation → Instructions and Data: builds instructions
src/zonc/bytecodegen/stmt_gen.py - Bytecode Emitter → Register Allocation: allocates registers
- Bytecode Emitter → ZonVM: writes bytecode for
- CLI Commands → Diagnostic Engine: reports failures
src/zonc/cli/cmd_zonc.py - Diagnostic Engine → Diagnostic Renderer: renders diagnostics
src/zonc/zonc_errors/engine.py - Diagnostic Renderer → Source Spans: uses spans
- Lexer → Diagnostic Engine: emits errors
src/zonc/scanner/lexer.py