Compilation Pipeline
v0.2Follow source through LLVM IR to a Windows executable.
On this page
Every build uses the same ordered stages for .prnc and .princi. The diagram shows the actual v0.2 path implemented by compiler::pipeline and the native backend.
- .prnc / .princiInterchangeable source file extensions
- SourceUTF-8 text with indexed source locations
- LexerLocated tokens
- ParserSyntax analysis with recovery
- ASTSpan-preserving source tree
- Module resolutionFixed built-in io and math registry
- Semantic analysisNames, types, bounds, conformance, and match coverage
- Generic specializationConcrete instances for used type arguments
- Typed representationAST plus specialized symbols and resolved expression types
- LLVM IRWindows target triple and runtime helpers
- Windows x86-64 COFFObject emitted by LLVM/Clang
- MinGW-w64 linkerGCC links the object and Windows C runtime
- .exeNative Windows x86-64 executable
#Frontend stages
- Source loading. The CLI resolves the source path and derives or normalizes the output path.
SourceFilereads UTF-8 text and indexes line starts for diagnostics. - Lexer. Source characters become tokens with source locations. Malformed literals and unexpected characters produce lexical diagnostics.
- Parser and AST. The parser consumes tokens, builds the source-oriented AST, and recovers at syntax boundaries to report errors. A build stops if parser diagnostics were collected.
- Module resolution. Imports are checked against the fixed, case-sensitive standard registry (
io,math). Resolution does not search files on disk. - Semantic analysis. Declarations, scopes, names, calls, assignments, control flow, generic bounds, implementations, matches, and types are checked. Generic specializations are resolved and success returns a typed representation. Any source errors stop the backend.
#Native stages
- LLVM IR.
codegen::llvmlowers the typed program and includes the explicitx86_64-w64-windows-gnutarget configuration and private runtime definitions. It also validates the entry point. - Windows object. Clang reads the generated LLVM IR, verifies it as it emits code, and writes a Windows x86-64 COFF object.
- Executable link. The compiler checks that the selected GCC targets
x86_64-w64-mingw32, then asks MinGW-w64 GCC to link the object and Windows C runtime into an.exe.
LLVM IR and object files live in a temporary build directory and are removed after success or failure. Set PRINCI_KEEP_INTERMEDIATES=1 to retain those compiler-development artifacts. The command remains princi build <source-file>; no intermediate path is required from the user.
#Failure boundaries
Source and semantic errors are reported before LLVM is generated. LLVM/Clang availability, LLVM/native emission, linker availability, and link failure have separate diagnostic codes. Failed builds return a nonzero process status and do not count as successful executable generation.