How quant-lang/quant works
Quant is a systems-language compiler that turns .qu source into native executables for supported OS/architecture targets. Its principal workflow is module loading, parsing into ASTs, attribute lowering and semantic analysis, IR generation and optimization, then native code generation and linking. Internally, compiler context holds shared type and symbol state used across stages. The README documents target and standard-library capabilities; some backend and runtime implementation files are not present in the supplied tree, so those links are documented rather than source-verified.
Main entry points: semantic.cpp Semantic analysis · modules.cpp Module manager · ast.h AST model · options.cpp CLI options
Components 20
Source and modules
- CLI options
src/utils/options.cpp - Module manager
src/modules/modules.cpp - Lexer
src/frontend/lexer.cpp - Parser
src/frontend/parser.cpp - AST model
include/quant/frontend/ast.h
Language analysis
- Attribute evaluation
src/attributes/attr_lowering.cpp - Semantic analysis
src/semantic/semantic.cpp - Comptime evaluator
src/comptime/evaluator.cpp - Dynamic lowering
src/attributes/attr_lowering.cpp
Native compilation
- IR generation
src/ir/ir_gen.cpp - IR optimizer
src/ir/opt.cpp - Native backend
src/main.cpp - Linker
src/linker/linker.cpp
Compiler state
- Symbol table
src/semantic/symbol_table.cpp - Type context
src/support/type_context.cpp - Compiler context
include/quant/support/compiler_context.h - Diagnostics
src/utils/errors.cpp
Other components
- Quant programmer
- Native executable
- Quant standard library
Connections 23
- Quant programmer → CLI options: provides source
- CLI options → Module manager: selects input
- Module manager → Lexer: loads and lexes
src/modules/modules.cpp - Module manager → Parser: parses modules
src/modules/modules.cpp - Parser → AST model: builds AST
src/frontend/parser.cpp - Module manager → AST model: merges module AST
- Attribute evaluation → AST model: rewrites attributes
- Semantic analysis → AST model: validates
src/semantic/semantic.cpp - Semantic analysis → Symbol table: resolves symbols
src/semantic/semantic.cpp - Semantic analysis → Type context: checks types
src/semantic/semantic.cpp - Semantic analysis → Comptime evaluator: evaluates constants
src/semantic/semantic.cpp - Dynamic lowering → AST model: lowers dynamics
- IR generation → AST model: generates IR
src/ir/ir_gen.cpp - IR generation → Type context: queries types
- IR optimizer → Native backend: passes optimized IR
src/main.cpp - Native backend → Native executable: emits machine code
- Linker → Native executable: links output
- CLI options → Compiler context: configures target
- Semantic analysis → Compiler context: uses shared state
src/semantic/semantic.cpp - Module manager → Compiler context: uses shared state
src/modules/modules.cpp - Semantic analysis → Diagnostics: reports errors
src/semantic/semantic.cpp - Module manager → Quant standard library: loads standard modules
- Linker → Quant standard library: links prebuilt archive