Expand description
Typed SST parsing built from pattern-derived instruction and type syntax.
A section’s .text is a flat instruction stream, not structured code:
@main:
execution::program::call 0, @helper
execution::program::ret 1
@helper:
execution::program::const_u64 21
execution::program::ret 1@name: binds a symbol to the address of the next instruction and occupies
no slot; @name in an operand refers to a symbol and is resolved through the
section’s symbol table during lowering. Each statement (a symbol definition,
an instruction, or @name: followed by an instruction) ends at the end of
its line and continues onto the next line only inside an open bracket; see
statements(). Indentation carries no meaning and ; starts a comment.
What a symbol is lives in the header: a function is a symbol with a
matching .func @name(...) directive, which supplies its signature and
locals. Its executable range runs from its symbol to the next function
symbol.
ParsedModule::parse_section yields the header, the code stream, and the
symbol table. ParsedModule::lower_with_metadata validates them against
the metadata, lowers instructions with their Lower<C> implementations,
and assembles a module. Its context can use
vihaco_module::loader::MetadataLoweringContext directly or wrap it to add
consumer capabilities.
With program-image-execution, HeaderDeclarations<D> parses a collection
of declarations, one per line. The standard directives
(vihaco_module::module::ProgramDirective: .file, .func, .entry,
.const, .source_symbol) are pushed into a
vihaco_module::module::ProgramHeader, which assembles the metadata;
consumers apply their own declarations to an application-owned preparation
context, then call lower_code_with_metadata with the completed metadata
and instruction context. This supports contexts borrowing prepared
configuration without moving the metadata during lowering.
See vihaco-stdlib/examples/loadable.rs for standard and application
directives in one header, metadata validation, and execution using dialect
instructions consumed by components. 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;pub use parse::symbol_definition;pub use spanned::ParsedDeclarations;pub use spanned::ParsedText;pub use spanned::Spanned;pub use spanned::SyntaxError;pub use spanned::parse_declarations;pub use spanned::parse_declarations_at;pub use spanned::parse_text;pub use spanned::parse_text_at;pub use statements::Statement;pub use statements::Statements;pub use statements::statements;
Modules§
- parse
- chumsky-0.10 combinators for the parsed-syntax shape.
- spanned
- Located, error-recovering parsers for
.textstreams and header declarations. - statements
- Splitting a block into statements: the line rules of SST.
Structs§
- Header
Declarations - Declarations parsed from one section header, one per line.
- Parsed
Module - One parsed SST section: its header and its flat
.textstream. - Symbol
- One symbol table entry: a name bound to an instruction address.
Traits§
- Surface
Instruction - Marker for enums whose pattern-derived parser represents instruction syntax.
Functions§
- lower_
code - Lower a code stream in address order.
- lower_
code_ with_ metadata - Validate supplied metadata and lower a code stream without consuming it.