Implement the P0/P1 frontend from spec/mapping.md, spec/evaluation.md: - units: heading scope index (level-1 namespace, level-2 function, level>=3 section), range computation, duplicate/empty-name diagnostics, GitHub anchor table kept separate from canonical ids, and warnings for would-be execution nodes outside function bodies. - map: AST-to-IR mapping where role comes from node kind + position. Strong is an execution statement, Emph a return, ordered list a branch, bullet list a loop sequence, block quote a call; invalid shapes are hard markdown.invalid_construct errors, never prose fallback. Payload parsing errors are mapped from payload-relative to file-relative spans. - payload: strict text/code payload concatenation with exact span mapping (including code-span delimiter handling) used to rewrite expression spans onto the source file. - signature: optional `(name: Type = const)` paragraph declaration; defaults must be compile-time constants; duplicates and malformed declarations are errors. - infer: definite-assignment data-flow parameter inference (must/may/ambiguous states, loop first-iteration handling, branch joins) per blueprint S-04. - calls: static call validation of arity/named arguments/builtin signatures after all signatures are known; inferred signatures accept named args only. - resources: inert Formula/Code resources with owning units and SHA-256 content hashes. - analyze: pipeline (parse -> units -> frontmatter imports -> map -> signature/ inference -> module -> call checks) that never executes anything. Tests include factorial recursion, loop counter, prose-invariance (IR equal modulo spans), and hard-error cases.
19 lines
612 B
Rust
19 lines
612 B
Rust
//! Marqdo frontend: Markdown AST → unit index → executable IR.
|
|
//!
|
|
//! The frontend is the semantic mapper described by
|
|
//! `spec/mapping.md`. It owns heading scopes, executable-role assignment,
|
|
//! payload parsing, signature/parameter analysis and static call validation.
|
|
//! It never executes user code and never touches the host boundary.
|
|
|
|
pub mod analyze;
|
|
pub mod calls;
|
|
pub mod infer;
|
|
pub mod map;
|
|
pub mod payload;
|
|
pub mod resources;
|
|
pub mod signature;
|
|
pub mod units;
|
|
|
|
pub use analyze::{analyze_source, AnalysisResult};
|
|
pub use units::{build_units, github_slug, FunctionScope, HeadingInfo, UnitIndex};
|