l0_driver.py
Module: l0_driver
Source: compiler/stage1_py/l0_driver.py Language: Python
Symbols
Namespace l0_driver
Function l0_driver.load_source_utf8
1
str l0_driver.load_source_utf8(str|Path path)
Read source bytes and decode as UTF-8.
UTF-8 BOM is accepted and silently stripped.
Parameters:
path: Path to the source file to read.
Returns: The decoded text content of the file.
Class l0_driver::ImportCycleError
Raised when a cyclic import is detected.
Class l0_driver::SourceEncodingError
Raised when a source file cannot be decoded as UTF-8.
Member Data l0_driver.SourceEncodingError.path
1
l0_driver.SourceEncodingError::path
Member Data l0_driver.SourceEncodingError.message
1
l0_driver.SourceEncodingError::message
Function l0_driver.SourceEncodingError.__init__
1
l0_driver.SourceEncodingError.__init__(self, str|Path path, str message)
Initialize a UTF-8 decoding failure.
Parameters:
path: Path to the source file that failed to decode.message: Human-readable explanation of the decoding failure.
See also:
load_source_utf8:Raises this exception for invalid source encodings.
Class l0_driver::L0Driver
Stage-1 driver for the L0 compiler.
Responsibilities include:
Reading source files.
Tokenizing (lexing).
Parsing.
Recursively resolving imports using SourceSearchPaths .
Entry points:
analyze(name): High-level analysis pipeline for an entry module.
build_compilation_unit(name): Build a closed set of modules for an entry.
load_module(name): Load by dotted module name, recursively loading imports.
load_single_file(path): Ad hoc one-off parsing (no import resolution).
Member Data l0_driver.L0Driver.search_paths
1
l0_driver.L0Driver::search_paths
Member Data l0_driver.L0Driver.context
1
l0_driver.L0Driver::context
Member Data l0_driver.L0Driver.diagnostics
1
l0_driver.L0Driver::diagnostics
Function l0_driver.L0Driver.__init__
1
l0_driver.L0Driver.__init__(self, SourceSearchPaths|None search_paths=None, CompilationContext|None context=None)
Initialize the L0 driver.
Parameters:
search_paths: Paths to search for modules. Defaults to an empty set of search paths.context: Compilation context for configuration and logging. Defaults to CompilationContext.default().Function
l0_driver.L0Driver.analyze
1
AnalysisResult l0_driver.L0Driver.analyze(self, str entry_module_name)
Execute the high-level front-end pipeline.
The pipeline consists of the following stages: 1. Build CompilationUnit for entry_module_name. 2. Run NameResolver (module-level symbols). 3. Run SignatureResolver (top-level types). 4. Run LocalScopeResolver (function/block scopes). 5. Run ExpressionTypeChecker (expression types).
Parameters:
entry_module_name: The name of the module to use as the entry point.
Returns: An AnalysisResult containing the compilation unit, environment information, and all collected diagnostics.
Function l0_driver.L0Driver.build_compilation_unit
1
CompilationUnit l0_driver.L0Driver.build_compilation_unit(self, str entry_module_name)
Build a compilation unit for an entry module.
Loads the entry module and recursively walks its imports to build the transitive closure of all required modules.
Parameters:
entry_module_name: The name of the entry module.
Returns: A CompilationUnit containing the entry module and all reachable modules.
Function l0_driver.L0Driver.load_module
1
Module l0_driver.L0Driver.load_module(self, str module_name)
Load a module by its qualified name.
Uses search paths to resolve the module name to a file, loads and parses it, and recursively loads all imported modules. Results are cached.
Parameters:
module_name: The qualified (dotted) name of the module.
Returns: The loaded and parsed Module object.
Function l0_driver.L0Driver._load_single_file
1
Module l0_driver.L0Driver._load_single_file(self, str|Path path)
Load a single file as a parsed module.
Ignores search paths and does not recursively resolve imports. The module is cached by its declared name.
Parameters:
path: Path to the source file.
Returns: The parsed Module object.
Function l0_driver.L0Driver._parse_source
1
Module l0_driver.L0Driver._parse_source(self, str text, str file_path)
Tokenize and parse source text.
Parameters:
text: The source code text.file_path: The path to the file (for diagnostics).
Returns: The parsed Module object.