Skip to main content

Crate vihaco_syntax

Crate vihaco_syntax 

Source
Expand description

Typed SST parsing built from pattern-derived instruction and type syntax.

Section owners select their header type and combine device declarations with the derived vihaco_module::module::ProgramMetadata record. The existing ParsedModule flow retains fn bodies and can validate them against supplied metadata. Instructions use their existing Lower<C> implementations. ParsedModule::lower_with_metadata combines validation, function-scope preparation, instruction lowering, and module assembly. Its context can use vihaco_module::loader::MetadataLoweringContext directly or add consumer capabilities by implementing vihaco_module::loader::FunctionScope.

With program-image-execution, HeaderDeclarations<D> parses a collection of semicolon-terminated declarations. Consumers apply declarations separately to an application-owned preparation context, then call lower_functions_with_metadata with the completed metadata and instruction context. This supports contexts borrowing prepared configuration without reconstructing a parsed module or moving its metadata during body lowering.

Metadata records use #[derive(Parse)] and #[syntax_class(metadata, open = "{", close = "}")] with an optional head. See vihaco-stdlib/examples/loadable.rs for header declarations, metadata validation, and execution using dialect instructions consumed by components.

A ParsedModule contains ParsedFunction values whose bodies are typed instruction vectors. Unknown or malformed instructions are parse errors. With typed-declarations, bodies can contain the generated syntax aggregate, lowered with a program loader’s capabilities before execution. Labels retain their instruction positions without emitting executable slots. Feature-off consumers retain the separate Resolve bridge.

Re-exports§

pub use parse::block_i64_flat;
pub use parse::block_i64_pairs;
pub use parse::skip;

Modules§

parse
chumsky-0.10 combinators for the parsed-syntax shape.

Structs§

HeaderDeclarations
Semicolon-terminated declarations parsed from one section header.
Param
ParsedFunction
ParsedLabel
A function-local label that occupies no executable instruction slot.
ParsedModule
Parsed SST module containing consumer instruction values.

Traits§

SurfaceInstruction
Marker for enums whose pattern-derived parser represents instruction syntax.

Functions§

lower_functions
Lower functions in source order, preparing each function’s complete label scope before lowering its first instruction.
lower_functions_with_metadata
Validate supplied metadata and lower function bodies without consuming it.