vihaco_syntax (crate)
vihaco_syntax¶
vihaco_syntax
Typed parsed-module syntax built from pattern-derived instruction and type syntax.
A ParsedModule contains ParsedFunction values whose bodies are typed instruction vectors. Unknown or malformed instructions are parse errors. Consumers implement Resolve to turn the typed parsed module into the runtime module their machine loads.
Modules
classParam¶source
vihaco_syntax::Param
Bases: Debug, Clone, StructuralPartialEq, PartialEq
Rust struct.
classParsedFunction¶source
vihaco_syntax::ParsedFunction
Bases: Debug, Clone, StructuralPartialEq, PartialEq, Parse<'src>
Rust struct.
pub struct ParsedFunction<I, Ty>Fields
| Name | Type | Description |
|---|---|---|
name | Ident | Function name with the leading `@` stripped (`@main` → `"main"`). |
params | Vec<Param<Ty>> | Function parameters parsed from `name: type` declarations. |
return_ty | Option<Ty> | Return type parsed with the consumer-provided `Ty` syntax. |
body | Vec<I> |
classParsedModule¶source
vihaco_syntax::ParsedModule
Bases: Debug, Clone, StructuralPartialEq, PartialEq
Rust struct. Parsed `.sst` module before resolution.
pub struct ParsedModule<I, Ty, H>Fields
| Name | Type | Description |
|---|---|---|
header | H | |
functions | Vec<ParsedFunction<I, Ty>> |
`I` is the consumer’s surface instruction type, `Ty` is its source type syntax, and `H` is its section-header type.
sourcemethodparse_section¶source
vihaco_syntax::ParsedModule::parse_section
Signature
pub fn parse_section<'src, C>(section: SstSectionView<'src, C>) -> Result<Self>Parameters
| Name | Type | Description |
|---|---|---|
section | SstSectionView<'src, C> |
Returns
Result<Self>
Parse a source section into a pre-resolution module.
sourceclassResolve¶source
vihaco_syntax::Resolve
Rust trait. Lower a parsed module to its resolved runtime form.
pub trait Resolve<I, Ty, H>Associated items
| Name | Type | Description |
|---|---|---|
Module | type Module | associated type. Resolved module type — concrete to the consumer (typically `crate::module::Module<I, Value, Type, Info>` with consumer-specific `Info`). |
Implementations own application-specific conversion such as translating typed surface variants, expanding explicitly modeled sugar, or interning parsed values.
sourcemethodresolve_module¶source
vihaco_syntax::Resolve::resolve_module
Signature
fn resolve_module(&mut self, parsed: ParsedModule<I, Ty, H>) -> Result<<Self as >::Module>Parameters
| Name | Type | Description |
|---|---|---|
parsed | ParsedModule<I, Ty, H> |
Returns
Result<<Self as >::Module>
functionblock_i64_flat¶source
vihaco_syntax::block_i64_flat
Signature
pub fn block_i64_flat<'src>() -> impl Parser<'src, &'src str, Vec<i64>, Err<Simple<'src, char>>> + CloneReturns
impl Parser<'src, &'src str, Vec<i64>, Err<Simple<'src, char>>> + Clone
Block-body helper: parse a sequence of whitespace-separated `i64`s as flat rows between an outer `{` … `}` provided by the caller. The body itself is a sequence of `i64`s with any whitespace (including newlines) between them.
Real usage: `device slm.filling { 0 1 2 3 };`.
sourcefunctionblock_i64_pairs¶source
vihaco_syntax::block_i64_pairs
Signature
pub fn block_i64_pairs<'src>() -> impl Parser<'src, &'src str, Vec<(i64, i64)>, Err<Simple<'src, char>>> + CloneReturns
impl Parser<'src, &'src str, Vec<(i64, i64)>, Err<Simple<'src, char>>> + Clone
Block-body helper: parse rows of `i64 i64` pairs separated by whitespace. Within a row the two ints are whitespace-separated; rows themselves are also just whitespace-separated (newlines or other ws — the helper doesn’t require row alignment).
Real usage: `device slm.traps { 1 1\n 5 1\n … };`, `device camera.detect_sites { … };`.
sourcefunctionskip¶source
vihaco_syntax::skip
Signature
pub fn skip<'src>() -> impl Parser<'src, &'src str, (), Err<Simple<'src, char>>> + CloneReturns
impl Parser<'src, &'src str, (), Err<Simple<'src, char>>> + Clone
Whitespace and `//`-to-end-of-line comments. Zero-or-more.
source