Skip to content

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

classParamsource

vihaco_syntax::Param

Bases: Debug, Clone, StructuralPartialEq, PartialEq

Rust struct.

pub struct Param<Ty>

Fields

NameTypeDescription
nameIdent
tyTy
source

classParsedFunctionsource

vihaco_syntax::ParsedFunction

Bases: Debug, Clone, StructuralPartialEq, PartialEq, Parse&lt;'src&gt;

Rust struct.

pub struct ParsedFunction<I, Ty>

Fields

NameTypeDescription
nameIdentFunction name with the leading `@` stripped (`@main` → `"main"`).
paramsVec&lt;Param&lt;Ty&gt;&gt;Function parameters parsed from `name: type` declarations.
return_tyOption&lt;Ty&gt;Return type parsed with the consumer-provided `Ty` syntax.
bodyVec&lt;I&gt;
source

classParsedModulesource

vihaco_syntax::ParsedModule

Bases: Debug, Clone, StructuralPartialEq, PartialEq

Rust struct. Parsed `.sst` module before resolution.

pub struct ParsedModule<I, Ty, H>

Fields

NameTypeDescription
headerH
functionsVec&lt;ParsedFunction&lt;I, Ty&gt;&gt;

`I` is the consumer’s surface instruction type, `Ty` is its source type syntax, and `H` is its section-header type.

source

methodparse_sectionsource

vihaco_syntax::ParsedModule::parse_section

Signature
pub fn parse_section<'src, C>(section: SstSectionView<'src, C>) -> Result<Self>

Parameters

NameTypeDescription
sectionSstSectionView&lt;'src, C&gt;

Returns

Result<Self>

Parse a source section into a pre-resolution module.

source

classResolvesource

vihaco_syntax::Resolve

Rust trait. Lower a parsed module to its resolved runtime form.

pub trait Resolve<I, Ty, H>

Associated items

NameTypeDescription
Moduletype Moduleassociated 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.

source

methodresolve_modulesource

vihaco_syntax::Resolve::resolve_module

Signature
fn resolve_module(&mut self, parsed: ParsedModule<I, Ty, H>) -> Result<<Self as >::Module>

Parameters

NameTypeDescription
parsedParsedModule&lt;I, Ty, H&gt;

Returns

Result<<Self as >::Module>

source

functionblock_i64_flatsource

vihaco_syntax::block_i64_flat

Signature
pub fn block_i64_flat<'src>() -> impl Parser<'src, &'src str, Vec<i64>, Err<Simple<'src, char>>> + Clone

Returns

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 };`.

source

functionblock_i64_pairssource

vihaco_syntax::block_i64_pairs

Signature
pub fn block_i64_pairs<'src>() -> impl Parser<'src, &'src str, Vec<(i64, i64)>, Err<Simple<'src, char>>> + Clone

Returns

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 { … };`.

source

functionskipsource

vihaco_syntax::skip

Signature
pub fn skip<'src>() -> impl Parser<'src, &'src str, (), Err<Simple<'src, char>>> + Clone

Returns

impl Parser<'src, &'src str, (), Err<Simple<'src, char>>> + Clone

Whitespace and `//`-to-end-of-line comments. Zero-or-more.

source