# Compiler-facing API
The compiler API is experimental. The stable-shaped entry point today is [`parse_file`](crate::parsing::parse_file); semantic pass objects remain exposed for development and may be reorganized before the first public release.
## Parsing source
```rust
use lehit::parsing::{SourceFile, parse_file};
let parsed = parse_file(SourceFile {
path: "app://answer.lt",
text: "let answer = 42",
}).unwrap();
assert_eq!(parsed.path, "app://answer.lt");
assert_eq!(parsed.ast.contract_definition_content.statements.len(), 1);
```
[`Span`](crate::parsing::Span) values are half-open UTF-8 byte ranges relative to the original source. AST [`StringId`](crate::parsing::ast::StringId) values are local to one [`ParsedFile`](crate::parsing::ParsedFile); use [`ParsedFile::string`](crate::parsing::ParsedFile::string) rather than combining IDs and string tables from different parses.
Lexing and syntax diagnostics are mutually exclusive in one [`ParseFailure`](crate::parsing::ParseFailure): syntax parsing starts only after lexing succeeds.
## Semantic stages
The current semantic pipeline is assembled from:
1. [`DeclarationIndex`](crate::semantic::DeclarationIndex);
2. [`ModuleGraph`](crate::semantic::ModuleGraph);
3. [`TypeLowerer`](crate::semantic::TypeLowerer);
4. [`FunctionRegistry`](crate::semantic::FunctionRegistry);
5. [`ExtensionEnvironment`](crate::semantic::ExtensionEnvironment) and [`MethodTable`](crate::semantic::MethodTable);
6. [`BodyAnalyzer`](crate::semantic::BodyAnalyzer), producing [`TypedBody`](crate::semantic::TypedBody).
These objects must originate from matching parsed files and module paths. IDs are generally local to the registry/body that created them and must not be cached across rebuilds unless a type explicitly documents stability.
## Core source
The files embedded by [`core_lib`](crate::core_lib) are the sole semantic source of truth for `core://` declarations. Compiler intrinsics are marked in source with `/* compiler function */`; runtime/codegen provides their physical implementation.
See [`crate::guides::architecture`] for pass ordering and [`crate::guides::maintenance_roadmap`] for the planned coordinated semantic facade.