Struct SourceAstFactory
pub struct SourceAstFactory;Description
Checked factory for owned source AST values.
The factory is intentionally syntax-only. It gives parsers, elaborators, and source transforms one construction boundary without exposing mutable declaration fields or requiring a format-and-reparse cycle.
Implementations§
§impl SourceAstFactory
impl SourceAstFactory
pub fn dimension_alias(
visibility: VisibilitySyntax,
name: impl Into<String>,
expression: Expr,
range: TextRange,
) -> Result<NamedDefinitionDecl, AstConstructionError>
pub fn dimension_alias( visibility: VisibilitySyntax, name: impl Into<String>, expression: Expr, range: TextRange, ) -> Result<NamedDefinitionDecl, AstConstructionError>
Construct one compilation-unit structural dimension alias.
§Errors
Returns an error for a malformed name, expression, or range.
pub fn parameter(
name: impl Into<String>,
value_type: ValueTypeSyntax,
value: Expr,
range: TextRange,
) -> Result<ParameterDecl, AstConstructionError>
pub fn parameter( name: impl Into<String>, value_type: ValueTypeSyntax, value: Expr, range: TextRange, ) -> Result<ParameterDecl, AstConstructionError>
Construct a model-level typed Parameter declaration.
§Errors
Returns an error for a non-finite value or malformed source shape.
pub fn observable(
name: impl Into<String>,
value_type: ValueTypeSyntax,
domain: Option<String>,
value: Expr,
range: TextRange,
) -> Result<ObservableDecl, AstConstructionError>
pub fn observable( name: impl Into<String>, value_type: ValueTypeSyntax, domain: Option<String>, value: Expr, range: TextRange, ) -> Result<ObservableDecl, AstConstructionError>
Construct a model-level typed Observable declaration.
§Errors
Returns an error for a non-finite value or malformed source shape.
pub fn coordinate(
name: impl Into<String>,
value_type: ValueTypeSyntax,
domain: impl Into<String>,
factor: Expr,
range: TextRange,
) -> Result<NamedDefinitionDecl, AstConstructionError>
pub fn coordinate( name: impl Into<String>, value_type: ValueTypeSyntax, domain: impl Into<String>, factor: Expr, range: TextRange, ) -> Result<NamedDefinitionDecl, AstConstructionError>
Construct an exact coordinate projection on a declared support. The selector is a factor name, optionally indexed by a literal axis.
§Errors
Rejects malformed names, ranges, or selectors that are not coordinate projections.
pub fn let_alias(
name: impl Into<String>,
value_type: Option<ValueTypeSyntax>,
domain: Option<String>,
activation: Option<String>,
value: Expr,
range: TextRange,
) -> Result<NamedDefinitionDecl, AstConstructionError>
pub fn let_alias( name: impl Into<String>, value_type: Option<ValueTypeSyntax>, domain: Option<String>, activation: Option<String>, value: Expr, range: TextRange, ) -> Result<NamedDefinitionDecl, AstConstructionError>
Construct a reusable immutable local expression alias.
§Errors
Returns an error for malformed source expressions, names, or ranges.
§impl SourceAstFactory
impl SourceAstFactory
pub fn clock_requirement(
name: impl Into<String>,
range: TextRange,
) -> Result<ClockRequirementDecl, AstConstructionError>
pub fn clock_requirement( name: impl Into<String>, range: TextRange, ) -> Result<ClockRequirementDecl, AstConstructionError>
Construct one borrowed exact-clock requirement without declaring a period.
§Errors
Rejects malformed identifiers and ranges.
pub fn component(
visibility: VisibilitySyntax,
name: impl Into<String>,
signature: Vec<SignatureItem>,
items: Vec<ComponentItem>,
range: TextRange,
) -> Result<ComponentDecl, AstConstructionError>
pub fn component( visibility: VisibilitySyntax, name: impl Into<String>, signature: Vec<SignatureItem>, items: Vec<ComponentItem>, range: TextRange, ) -> Result<ComponentDecl, AstConstructionError>
Construct one reusable Component declaration.
§Errors
Returns an error for an invalid source identifier, member shape, or byte range.
pub fn with_formulation_gauge(
component: ComponentDecl,
form_name: &str,
field: impl Into<String>,
conditions: [(Expr, Expr); 2],
) -> Result<ComponentDecl, AstConstructionError>
pub fn with_formulation_gauge( component: ComponentDecl, form_name: &str, field: impl Into<String>, conditions: [(Expr, Expr); 2], ) -> Result<ComponentDecl, AstConstructionError>
Attach an explicit constant scalar gauge to one existing Formulation. The ordered equalities are its reference and load compatibility condition.
§Errors
Rejects malformed expressions, an unknown form, or a repeated gauge declaration.
pub fn component_with_form(
visibility: VisibilitySyntax,
name: impl Into<String>,
signature: Vec<SignatureItem>,
items: Vec<ComponentItem>,
form: (String, Vec<String>, FormulationBinding),
equalities: (Vec<(Expr, Expr)>, TextRange),
range: TextRange,
) -> Result<ComponentDecl, AstConstructionError>
pub fn component_with_form( visibility: VisibilitySyntax, name: impl Into<String>, signature: Vec<SignatureItem>, items: Vec<ComponentItem>, form: (String, Vec<String>, FormulationBinding), equalities: (Vec<(Expr, Expr)>, TextRange), range: TextRange, ) -> Result<ComponentDecl, AstConstructionError>
Construct a Component with one bound mathematical formulation after its members.
§Errors
Returns an error for an invalid member, identifier, expression, or byte range.
§impl SourceAstFactory
impl SourceAstFactory
pub fn with_enumeration(document: Document, declaration: EnumDecl) -> Document
pub fn with_enumeration(document: Document, declaration: EnumDecl) -> Document
Append a checked enum declaration to an owned compilation module.
pub fn model(
visibility: VisibilitySyntax,
name: impl Into<String>,
signature: Vec<SignatureItem>,
items: Vec<Item>,
range: TextRange,
) -> Result<ModelDecl, AstConstructionError>
pub fn model( visibility: VisibilitySyntax, name: impl Into<String>, signature: Vec<SignatureItem>, items: Vec<Item>, range: TextRange, ) -> Result<ModelDecl, AstConstructionError>
Construct one named flat model from already checked Item values.
§Errors
Returns an error for an invalid source identifier or byte range.
pub fn model_with_form(
visibility: VisibilitySyntax,
name: impl Into<String>,
signature: Vec<SignatureItem>,
items: Vec<Item>,
form: (String, Vec<String>, FormulationBinding),
equalities: (Vec<(Expr, Expr)>, TextRange),
range: TextRange,
) -> Result<ModelDecl, AstConstructionError>
pub fn model_with_form( visibility: VisibilitySyntax, name: impl Into<String>, signature: Vec<SignatureItem>, items: Vec<Item>, form: (String, Vec<String>, FormulationBinding), equalities: (Vec<(Expr, Expr)>, TextRange), range: TextRange, ) -> Result<ModelDecl, AstConstructionError>
Construct a Model with one bound mathematical formulation after its members.
§Errors
Rejects invalid members, identifiers, expressions, or byte ranges.
pub fn with_model_signature(
model: ModelDecl,
signature: Vec<SignatureItem>,
) -> Result<ModelDecl, AstConstructionError>
pub fn with_model_signature( model: ModelDecl, signature: Vec<SignatureItem>, ) -> Result<ModelDecl, AstConstructionError>
Replace a Model signature while retaining its declarations and authored forms.
§Errors
Rejects an invalid signature.
pub fn with_import(
document: Document,
module: NamePath,
alias: Option<String>,
range: TextRange,
) -> Result<Document, AstConstructionError>
pub fn with_import( document: Document, module: NamePath, alias: Option<String>, range: TextRange, ) -> Result<Document, AstConstructionError>
Add one explicit semantic module import to a source document.
§Errors
Returns an error for an invalid qualified module, alias, or source range.
pub fn document_with_dimensions(
enumerations: Vec<EnumDecl>,
dimensions: Vec<NamedDefinitionDecl>,
connectors: Vec<ConnectorDecl>,
components: Vec<ComponentDecl>,
pure_operators: Vec<PureOperatorDecl>,
models: Vec<ModelDecl>,
) -> Result<Document, AstConstructionError>
pub fn document_with_dimensions( enumerations: Vec<EnumDecl>, dimensions: Vec<NamedDefinitionDecl>, connectors: Vec<ConnectorDecl>, components: Vec<ComponentDecl>, pure_operators: Vec<PureOperatorDecl>, models: Vec<ModelDecl>, ) -> Result<Document, AstConstructionError>
Close one compilation unit with an ordered structural-dimension prefix.
§Errors
Returns an error when the compilation unit contains no declaration.
pub fn document(
enumerations: Vec<EnumDecl>,
connectors: Vec<ConnectorDecl>,
components: Vec<ComponentDecl>,
models: Vec<ModelDecl>,
) -> Result<Document, AstConstructionError>
pub fn document( enumerations: Vec<EnumDecl>, connectors: Vec<ConnectorDecl>, components: Vec<ComponentDecl>, models: Vec<ModelDecl>, ) -> Result<Document, AstConstructionError>
Close one nonempty compilation unit into a formatter-compatible document.
A declarations-only document is valid source syntax for a package library. Executable compilation still requires at least one Model.
§Errors
Returns an error when the compilation unit is empty.
pub fn document_with_pure_operators(
enumerations: Vec<EnumDecl>,
connectors: Vec<ConnectorDecl>,
components: Vec<ComponentDecl>,
pure_operators: Vec<PureOperatorDecl>,
models: Vec<ModelDecl>,
) -> Result<Document, AstConstructionError>
pub fn document_with_pure_operators( enumerations: Vec<EnumDecl>, connectors: Vec<ConnectorDecl>, components: Vec<ComponentDecl>, pure_operators: Vec<PureOperatorDecl>, models: Vec<ModelDecl>, ) -> Result<Document, AstConstructionError>
Close one nonempty compilation unit including pure operators.
§Errors
Returns an error when the compilation unit is empty.
pub fn flat_document(
models: Vec<ModelDecl>,
) -> Result<Document, AstConstructionError>
pub fn flat_document( models: Vec<ModelDecl>, ) -> Result<Document, AstConstructionError>
Close one or more flat models into a formatter-compatible document.
§Errors
Returns an error when models is empty, matching the source grammar.
§impl SourceAstFactory
impl SourceAstFactory
pub fn reduction(
operation: ReductionOp,
binder: FamilyBinderSyntax,
value: Expr,
range: TextRange,
) -> Result<Expr, AstConstructionError>
pub fn reduction( operation: ReductionOp, binder: FamilyBinderSyntax, value: Expr, range: TextRange, ) -> Result<Expr, AstConstructionError>
Construct a bounded scalar reduction with an explicit lexical binder.
§Errors
Rejects malformed binder names/ranges or excessive expression depth. The compiler checks index-set identity, cardinality, and scalar domain.
§impl SourceAstFactory
impl SourceAstFactory
pub fn property_requirement(
name: impl Into<String>,
contract: NamePath,
range: TextRange,
) -> Result<ComponentPropertyDecl, AstConstructionError>
pub fn property_requirement( name: impl Into<String>, contract: NamePath, range: TextRange, ) -> Result<ComponentPropertyDecl, AstConstructionError>
Construct a nominal property requirement in a shared signature.
§Errors
Rejects malformed names, paths, and ranges.
§impl SourceAstFactory
impl SourceAstFactory
pub fn condition(
kind: RelationConditionKind,
left: Expr,
right: Expr,
range: TextRange,
) -> Result<RelationCondition, AstConstructionError>
pub fn condition( kind: RelationConditionKind, left: Expr, right: Expr, range: TextRange, ) -> Result<RelationCondition, AstConstructionError>
Construct a mathematical condition without disguising it as a Boolean or equality. Complementarity operands are explicit nonnegativity predicates; the compiler checks their literal zero, real order, units and exact supports.
§Errors
Rejects malformed expressions or ranges; mathematical admission remains compiler-owned.
§impl SourceAstFactory
impl SourceAstFactory
pub fn enumeration(
visibility: VisibilitySyntax,
name: impl Into<String>,
tags: Vec<NamePath>,
range: TextRange,
) -> Result<EnumDecl, AstConstructionError>
pub fn enumeration( visibility: VisibilitySyntax, name: impl Into<String>, tags: Vec<NamePath>, range: TextRange, ) -> Result<EnumDecl, AstConstructionError>
Construct a module enum with nonempty distinct tag tokens in authored order.
§Errors
Rejects malformed names/ranges, duplicate tags, or excessive cardinality.
pub fn case_arm_value(
arm: &CaseArm,
value: Expr,
) -> Result<CaseArm, AstConstructionError>
pub fn case_arm_value( arm: &CaseArm, value: Expr, ) -> Result<CaseArm, AstConstructionError>
Replace a case arm value while preserving its checked pattern identity.
§Errors
Rejects malformed replacement expressions or arm ranges.
pub fn case_arm(
pattern: NamePath,
value: Expr,
range: TextRange,
) -> Result<CaseArm, AstConstructionError>
pub fn case_arm( pattern: NamePath, value: Expr, range: TextRange, ) -> Result<CaseArm, AstConstructionError>
Construct an explicit qualified-tag case arm without introducing a binder.
§Errors
Rejects nonqualified patterns, wildcards, malformed expressions or ranges.
§impl SourceAstFactory
impl SourceAstFactory
pub fn event(
name: impl Into<String>,
guard: Expr,
direction: EventDirection,
priority: i64,
range: TextRange,
) -> Result<EventDecl, AstConstructionError>
pub fn event( name: impl Into<String>, guard: Expr, direction: EventDirection, priority: i64, range: TextRange, ) -> Result<EventDecl, AstConstructionError>
Construct an event with inferred guard type, crossing direction and static priority.
§Errors
Rejects invalid names, ranges, and unbounded or malformed guard syntax. Scalar guard type and event scope are validated by the common compiler.
§impl SourceAstFactory
impl SourceAstFactory
pub fn law(
name: impl Into<String>,
domain: impl Into<String>,
storage: Option<Expr>,
flux: Expr,
source: Expr,
range: TextRange,
) -> Result<RelationDecl, AstConstructionError>
pub fn law( name: impl Into<String>, domain: impl Into<String>, storage: Option<Expr>, flux: Expr, source: Expr, range: TextRange, ) -> Result<RelationDecl, AstConstructionError>
Construct a fixed-domain conservation Law with an outward physical flux.
Omit storage only for a steady balance. Supply source explicitly, using a typed zero where production is absent. Mathematical admission belongs to the compiler and kernel, independently of a numerical method.
§Errors
Rejects malformed names, term expressions, or source ranges.
§impl SourceAstFactory
impl SourceAstFactory
pub fn finite_space(
visibility: VisibilitySyntax,
name: impl Into<String>,
labels: Vec<String>,
range: TextRange,
) -> Result<NamedDefinitionDecl, AstConstructionError>
pub fn finite_space( visibility: VisibilitySyntax, name: impl Into<String>, labels: Vec<String>, range: TextRange, ) -> Result<NamedDefinitionDecl, AstConstructionError>
Construct a finite space with nonempty, distinct, ordered basis labels.
§Errors
Rejects invalid identifiers, repeated or absent labels, and malformed ranges.
pub fn finite_product(
visibility: VisibilitySyntax,
name: impl Into<String>,
factors: [NamePath; 2],
range: TextRange,
) -> Result<NamedDefinitionDecl, AstConstructionError>
pub fn finite_product( visibility: VisibilitySyntax, name: impl Into<String>, factors: [NamePath; 2], range: TextRange, ) -> Result<NamedDefinitionDecl, AstConstructionError>
Construct an alias for an ordered pair of primal atomic spaces.
§Errors
Rejects malformed names and ranges; factor identity is checked during binding.
pub fn index_set(
name: impl Into<String>,
extent: Expr,
range: TextRange,
) -> Result<NamedDefinitionDecl, AstConstructionError>
pub fn index_set( name: impl Into<String>, extent: Expr, range: TextRange, ) -> Result<NamedDefinitionDecl, AstConstructionError>
Construct an index-set declaration, preserving its exact extent expression. Integer type, positivity, and structural resource bounds are elaboration checks.
§Errors
Rejects malformed names, expression trees, and byte ranges.
pub fn index_family_binder(
binder: impl Into<String>,
set: NamePath,
range: TextRange,
) -> Result<FamilyBinderSyntax, AstConstructionError>
pub fn index_family_binder( binder: impl Into<String>, set: NamePath, range: TextRange, ) -> Result<FamilyBinderSyntax, AstConstructionError>
Construct a local binder over one nominal index-set name.
§Errors
Rejects malformed identifiers, name paths, and byte ranges.
§impl SourceAstFactory
impl SourceAstFactory
pub fn with_finite_space(
document: Document,
declaration: NamedDefinitionDecl,
) -> Result<Document, AstConstructionError>
pub fn with_finite_space( document: Document, declaration: NamedDefinitionDecl, ) -> Result<Document, AstConstructionError>
Add one checked nominal space to an existing compilation unit.
pub fn bind_nominal_value_type(
syntax: &mut ValueTypeSyntax,
value: ValueType,
) -> Result<(), AstConstructionError>
pub fn bind_nominal_value_type( syntax: &mut ValueTypeSyntax, value: ValueType, ) -> Result<(), AstConstructionError>
Attach a checked lexical nominal binding while retaining authored syntax.
§Errors
Rejects a value type with a different nominal role or invalid source bounds.
§impl SourceAstFactory
impl SourceAstFactory
pub fn exact_integer(
spelling: impl Into<String>,
range: TextRange,
) -> Result<ExactIntegerSyntax, AstConstructionError>
pub fn exact_integer( spelling: impl Into<String>, range: TextRange, ) -> Result<ExactIntegerSyntax, AstConstructionError>
Construct one exact integer token used by pure-operator syntax.
§Errors
Rejects non-decimal or u64-overflowing spelling and reversed ranges.
pub fn pure_operator_formal(
name: impl Into<String>,
value_class: PureValueClassSyntax,
range: TextRange,
) -> Result<PureOperatorFormal, AstConstructionError>
pub fn pure_operator_formal( name: impl Into<String>, value_class: PureValueClassSyntax, range: TextRange, ) -> Result<PureOperatorFormal, AstConstructionError>
Construct one ordered pure-operator formal.
§Errors
Returns an error for an invalid name, value class, or source range.
pub fn pure_operator(
visibility: VisibilitySyntax,
name: impl Into<String>,
formals: Vec<PureOperatorFormal>,
result: PureValueClassSyntax,
body: Expr,
range: TextRange,
) -> Result<PureOperatorDecl, AstConstructionError>
pub fn pure_operator( visibility: VisibilitySyntax, name: impl Into<String>, formals: Vec<PureOperatorFormal>, result: PureValueClassSyntax, body: Expr, range: TextRange, ) -> Result<PureOperatorDecl, AstConstructionError>
Construct one top-level pure operator declaration.
§Errors
Returns an error for an invalid name, an empty formal list, duplicate formal names, malformed exact syntax, or a reversed source range.
§impl SourceAstFactory
impl SourceAstFactory
pub fn elaborate_property_terms(
document: &mut Document,
contract_types: &BTreeMap<String, ValueTypeSyntax>,
release_values: &BTreeMap<String, Expr>,
property_targets: &BTreeMap<String, Vec<String>>,
) -> Result<(), AstConstructionError>
pub fn elaborate_property_terms( document: &mut Document, contract_types: &BTreeMap<String, ValueTypeSyntax>, release_values: &BTreeMap<String, Expr>, property_targets: &BTreeMap<String, Vec<String>>, ) -> Result<(), AstConstructionError>
Materialize compiler-validated property requirements and exact release bindings.
§Errors
Rejects absent validated contract or release projections.
§impl SourceAstFactory
impl SourceAstFactory
pub fn with_property_contract(
document: Option<Document>,
name: String,
value_type: ValueTypeSyntax,
profile: (Vec<(String, ValueTypeSyntax)>, PropertyDerivatives, Option<NamePath>),
range: TextRange,
) -> Result<Document, AstConstructionError>
pub fn with_property_contract( document: Option<Document>, name: String, value_type: ValueTypeSyntax, profile: (Vec<(String, ValueTypeSyntax)>, PropertyDerivatives, Option<NamePath>), range: TextRange, ) -> Result<Document, AstConstructionError>
Create or extend a compilation module with one checked property contract.
§Errors
Rejects malformed names, result syntax, or source ranges.
pub fn property_table(
data: NamePath,
axis: (String, Expr),
value: (String, Expr),
validity: [Expr; 2],
range: TextRange,
) -> Result<PropertySourceSyntax, AstConstructionError>
pub fn property_table( data: NamePath, axis: (String, Expr), value: (String, Expr), validity: [Expr; 2], range: TextRange, ) -> Result<PropertySourceSyntax, AstConstructionError>
Construct the fixed piecewise-affine table source profile.
§Errors
Rejects malformed references, column names, dimensions, or ranges.
pub fn with_property_release(
document: Option<Document>,
name: String,
contract: NamePath,
source: (PropertySourceSyntax, Expr, Expr),
attribution: (NamePath, NamePath),
profile: (Option<Expr>, Option<NamePath>),
range: TextRange,
) -> Result<Document, AstConstructionError>
pub fn with_property_release( document: Option<Document>, name: String, contract: NamePath, source: (PropertySourceSyntax, Expr, Expr), attribution: (NamePath, NamePath), profile: (Option<Expr>, Option<NamePath>), range: TextRange, ) -> Result<Document, AstConstructionError>
Append one property release with explicit scientific source metadata.
§Errors
Rejects malformed names, expressions, or ranges. The compiler owns nominal contract, dimensional, scaling, and value admission.
pub fn with_material_composition(
document: Document,
name: String,
properties: Vec<(String, NamePath, TextRange)>,
range: TextRange,
) -> Result<Document, AstConstructionError>
pub fn with_material_composition( document: Document, name: String, properties: Vec<(String, NamePath, TextRange)>, range: TextRange, ) -> Result<Document, AstConstructionError>
Append an explicit finite property composition.
§Errors
Rejects empty bindings, malformed names, paths, or source ranges.
§impl SourceAstFactory
impl SourceAstFactory
pub fn record_member(
name: impl Into<String>,
value_type: ValueTypeSyntax,
range: TextRange,
) -> Result<RecordMemberDecl, AstConstructionError>
pub fn record_member( name: impl Into<String>, value_type: ValueTypeSyntax, range: TextRange, ) -> Result<RecordMemberDecl, AstConstructionError>
pub fn record(
visibility: VisibilitySyntax,
name: impl Into<String>,
members: Vec<RecordMemberDecl>,
range: TextRange,
) -> Result<RecordDecl, AstConstructionError>
pub fn record( visibility: VisibilitySyntax, name: impl Into<String>, members: Vec<RecordMemberDecl>, range: TextRange, ) -> Result<RecordDecl, AstConstructionError>
Construct a nonempty closed record with unique declaration-ordered members.
§Errors
Rejects invalid names/ranges, duplicate members, or excessive cardinality.
pub fn with_record(document: Document, declaration: RecordDecl) -> Document
pub fn with_record(document: Document, declaration: RecordDecl) -> Document
Append a checked closed record declaration to an owned module.
§impl SourceAstFactory
impl SourceAstFactory
pub fn initial(
equations: Vec<RelationCondition>,
range: TextRange,
) -> Result<InitialDecl, AstConstructionError>
pub fn initial( equations: Vec<RelationCondition>, range: TextRange, ) -> Result<InitialDecl, AstConstructionError>
Construct simultaneous mathematical initialization conditions.
§Errors
Rejects empty conditions, malformed expressions, and invalid byte ranges.
pub fn equation(
left: Expr,
right: Expr,
range: TextRange,
) -> Result<RelationCondition, AstConstructionError>
pub fn equation( left: Expr, right: Expr, range: TextRange, ) -> Result<RelationCondition, AstConstructionError>
Construct an ordered equality without interpreting either side.
§Errors
Returns an error for a malformed expression or range.
pub fn relation(
name: impl Into<String>,
activation: ActivationSyntax,
domain: Option<String>,
equations: Vec<RelationCondition>,
range: TextRange,
) -> Result<RelationDecl, AstConstructionError>
pub fn relation( name: impl Into<String>, activation: ActivationSyntax, domain: Option<String>, equations: Vec<RelationCondition>, range: TextRange, ) -> Result<RelationDecl, AstConstructionError>
Construct an implicit Relation with at least one equality.
§Errors
Returns an error for an empty equation set or malformed source shape.
pub fn relation_family(
relation: RelationDecl,
binder: FamilyBinderSyntax,
) -> Result<RelationFamilyDecl, AstConstructionError>
pub fn relation_family( relation: RelationDecl, binder: FamilyBinderSyntax, ) -> Result<RelationFamilyDecl, AstConstructionError>
Construct one Relation family over an exact finite set.
§Errors
Rejects malformed binders or equations. The compiler determines the set kind and checks support and activation restrictions.
§impl SourceAstFactory
impl SourceAstFactory
pub fn value_literal<'a>(
value: &ValueLiteral,
frame: Option<NamePath>,
range: TextRange,
resolve: impl FnMut(RawId) -> Option<NamePath>,
resolve_enum: impl FnMut(RawId) -> Option<&'a EnumDef>,
resolve_product: impl FnMut(FiniteBasis) -> Option<NamePath>,
) -> Result<Expr, AstConstructionError>
pub fn value_literal<'a>( value: &ValueLiteral, frame: Option<NamePath>, range: TextRange, resolve: impl FnMut(RawId) -> Option<NamePath>, resolve_enum: impl FnMut(RawId) -> Option<&'a EnumDef>, resolve_product: impl FnMut(FiniteBasis) -> Option<NamePath>, ) -> Result<Expr, AstConstructionError>
Project one complete coherent-SI value into the canonical source vocabulary.
§Errors
Rejects excessive type cardinality/nesting, a frame on an invariant value, or nonzero spatial components without an explicit frame.
§impl SourceAstFactory
impl SourceAstFactory
pub fn tensor_value(
frame: NamePath,
components: Expr,
range: TextRange,
) -> Result<Expr, AstConstructionError>
pub fn tensor_value( frame: NamePath, components: Expr, range: TextRange, ) -> Result<Expr, AstConstructionError>
Construct a spatial coefficient in the named support’s Cartesian frame. The frame reference does not give the coefficient spatial support.
§Errors
Rejects invalid names, ranges, or expressions exceeding source bounds.
§impl SourceAstFactory
impl SourceAstFactory
pub fn value_type(
kind: ValueTypeSyntaxKind,
range: TextRange,
) -> Result<ValueTypeSyntax, AstConstructionError>
pub fn value_type( kind: ValueTypeSyntaxKind, range: TextRange, ) -> Result<ValueTypeSyntax, AstConstructionError>
Construct a bounded mathematical source type without parsing text.
§Errors
Rejects invalid scalar components, extents, nesting, expressions or ranges.
§impl SourceAstFactory
impl SourceAstFactory
pub const MAX_EXPRESSION_DEPTH: usize = 256
pub const MAX_EXPRESSION_DEPTH: usize = 256
Maximum depth of one directly constructed expression tree.
pub const MAX_EXPRESSION_NODES: usize = 1_000_000
pub const MAX_EXPRESSION_NODES: usize = 1_000_000
Maximum expression nodes admitted by one compilation module.
pub const MAX_CONTAINER_MEMBERS: usize = 65_536
pub const MAX_CONTAINER_MEMBERS: usize = 65_536
Maximum declarations or equation members in one source container.
pub fn connector(
visibility: VisibilitySyntax,
name: impl Into<String>,
syntax: ConnectorSyntax,
range: TextRange,
) -> Result<ConnectorDecl, AstConstructionError>
pub fn connector( visibility: VisibilitySyntax, name: impl Into<String>, syntax: ConnectorSyntax, range: TextRange, ) -> Result<ConnectorDecl, AstConstructionError>
Construct one nominal Connector declaration.
§Errors
Returns an error for malformed visibility-independent source shape, name, expression, or byte range.
pub fn connector_quantity(
name: impl Into<String>,
dimension: Expr,
) -> Result<ConnectorQuantitySyntax, AstConstructionError>
pub fn connector_quantity( name: impl Into<String>, dimension: Expr, ) -> Result<ConnectorQuantitySyntax, AstConstructionError>
Construct one named field-physical Connector quantity.
§Errors
Returns an error for a malformed member name or dimension expression.
pub fn component_parameter(
visibility: VisibilitySyntax,
name: impl Into<String>,
value_type: ValueTypeSyntax,
default: Option<Expr>,
range: TextRange,
) -> Result<ComponentParameterDecl, AstConstructionError>
pub fn component_parameter( visibility: VisibilitySyntax, name: impl Into<String>, value_type: ValueTypeSyntax, default: Option<Expr>, range: TextRange, ) -> Result<ComponentParameterDecl, AstConstructionError>
Construct one component-local scalar Parameter.
§Errors
Returns an error for a malformed name, expression, or byte range.
pub fn component_port(
visibility: VisibilitySyntax,
name: impl Into<String>,
syntax: PortSyntax,
range: TextRange,
) -> Result<ComponentPortDecl, AstConstructionError>
pub fn component_port( visibility: VisibilitySyntax, name: impl Into<String>, syntax: PortSyntax, range: TextRange, ) -> Result<ComponentPortDecl, AstConstructionError>
Construct one component-local Port.
§Errors
Returns an error for malformed Port syntax, a name, or a byte range.
pub fn component_port_family(
port: ComponentPortDecl,
binder: FamilyBinderSyntax,
) -> Result<ComponentPortFamilyDecl, AstConstructionError>
pub fn component_port_family( port: ComponentPortDecl, binder: FamilyBinderSyntax, ) -> Result<ComponentPortFamilyDecl, AstConstructionError>
Construct one field-physical Port family over a complete exterior.
§Errors
Returns an error unless the Port is field-physical, its support names the binder member, and both declarations are structurally valid.
pub fn boundary_family_binder(
member: impl Into<String>,
set: impl Into<String>,
range: TextRange,
) -> Result<FamilyBinderSyntax, AstConstructionError>
pub fn boundary_family_binder( member: impl Into<String>, set: impl Into<String>, range: TextRange, ) -> Result<FamilyBinderSyntax, AstConstructionError>
Construct the restricted [member in complete_exterior] binder.
§Errors
Returns an error for malformed identifiers or a reversed range.
pub fn support_slot(
visibility: VisibilitySyntax,
name: impl Into<String>,
syntax: SupportSlotSyntax,
range: TextRange,
) -> Result<SupportSlotDecl, AstConstructionError>
pub fn support_slot( visibility: VisibilitySyntax, name: impl Into<String>, syntax: SupportSlotSyntax, range: TextRange, ) -> Result<SupportSlotDecl, AstConstructionError>
Construct one component-local spatial-support slot.
§Errors
Returns an error for a malformed slot name, parent name, or byte range. Support-graph and visibility rules remain compiler responsibilities.
pub fn domain(
name: impl Into<String>,
syntax: DomainSyntax,
range: TextRange,
) -> Result<DomainDecl, AstConstructionError>
pub fn domain( name: impl Into<String>, syntax: DomainSyntax, range: TextRange, ) -> Result<DomainDecl, AstConstructionError>
Construct a Domain declaration.
§Errors
Returns an error for malformed source shape, names, expressions, or ranges. Geometric and dimensional meaning remains a lowering check.
pub fn field(
name: impl Into<String>,
domain: Option<String>,
role: FieldRoleSyntax,
spatial_regularity: SpatialRegularity,
activation: ActivationSyntax,
value_type: ValueTypeSyntax,
range: TextRange,
) -> Result<FieldDecl, AstConstructionError>
pub fn field( name: impl Into<String>, domain: Option<String>, role: FieldRoleSyntax, spatial_regularity: SpatialRegularity, activation: ActivationSyntax, value_type: ValueTypeSyntax, range: TextRange, ) -> Result<FieldDecl, AstConstructionError>
Construct an owned unknown with independent role, support, and activation.
§Errors
Rejects malformed identifiers, complete type syntax, or byte ranges.
pub fn port(
name: impl Into<String>,
syntax: PortSyntax,
range: TextRange,
) -> Result<PortDecl, AstConstructionError>
pub fn port( name: impl Into<String>, syntax: PortSyntax, range: TextRange, ) -> Result<PortDecl, AstConstructionError>
Construct a model-level Port declaration.
§Errors
Returns an error for malformed Port syntax, names, or ranges.
pub fn clock(
name: impl Into<String>,
period: Expr,
phase: Expr,
range: TextRange,
) -> Result<ClockDecl, AstConstructionError>
pub fn clock( name: impl Into<String>, period: Expr, phase: Expr, range: TextRange, ) -> Result<ClockDecl, AstConstructionError>
Construct an exact periodic Clock declaration.
Exact time admission, rational reduction, and nonzero-period checks remain semantic lowering checks, matching parsed source behavior.
§Errors
Returns an error for an invalid identifier, range, or expression tree.
pub fn connection(
syntax: ConnectionSyntax,
binder: Option<FamilyBinderSyntax>,
ports: Vec<Expr>,
range: TextRange,
) -> Result<ConnectionDecl, AstConstructionError>
pub fn connection( syntax: ConnectionSyntax, binder: Option<FamilyBinderSyntax>, ports: Vec<Expr>, range: TextRange, ) -> Result<ConnectionDecl, AstConstructionError>
Construct a signal or conserving Connection with at least two Ports.
§Errors
Returns an error for insufficient members or malformed paths/ranges.
pub fn boundary_connection(
binder: Option<FamilyBinderSyntax>,
ports: Vec<BoundaryPortReferenceSyntax>,
range: TextRange,
) -> Result<BoundaryConnectionDecl, AstConstructionError>
pub fn boundary_connection( binder: Option<FamilyBinderSyntax>, ports: Vec<BoundaryPortReferenceSyntax>, range: TextRange, ) -> Result<BoundaryConnectionDecl, AstConstructionError>
Construct one conserving Connection with boundary-family Port references.
§Errors
Returns an error for fewer than two Ports, malformed references, or a declaration containing neither a family binder nor a selector.
pub fn spatial_periodic_boundary_connection(
ports: Vec<BoundaryPortReferenceSyntax>,
range: TextRange,
) -> Result<BoundaryConnectionDecl, AstConstructionError>
pub fn spatial_periodic_boundary_connection( ports: Vec<BoundaryPortReferenceSyntax>, range: TextRange, ) -> Result<BoundaryConnectionDecl, AstConstructionError>
Construct one exact spatial-periodic pair in a closed Model.
§Errors
Returns an error unless there are exactly two boundary Ports.
pub fn boundary_port_reference(
port: NamePath,
selector: Option<BoundaryPortSelectorSyntax>,
) -> Result<BoundaryPortReferenceSyntax, AstConstructionError>
pub fn boundary_port_reference( port: NamePath, selector: Option<BoundaryPortSelectorSyntax>, ) -> Result<BoundaryPortReferenceSyntax, AstConstructionError>
Construct one Port path with an optional exact boundary selector.
§Errors
Returns an error for a malformed path or selector.
pub fn boundary_port_selector(
member: impl Into<String>,
target: impl Into<String>,
range: TextRange,
) -> Result<BoundaryPortSelectorSyntax, AstConstructionError>
pub fn boundary_port_selector( member: impl Into<String>, target: impl Into<String>, range: TextRange, ) -> Result<BoundaryPortSelectorSyntax, AstConstructionError>
Construct the closed [member = target] Port selector.
§Errors
Returns an error for malformed identifiers or a reversed range.
pub fn instance(
name: impl Into<String>,
definition: NamePath,
family: Option<FamilyBinderSyntax>,
bindings: Vec<NamedBindingDecl>,
range: TextRange,
) -> Result<InstanceDecl, AstConstructionError>
pub fn instance( name: impl Into<String>, definition: NamePath, family: Option<FamilyBinderSyntax>, bindings: Vec<NamedBindingDecl>, range: TextRange, ) -> Result<InstanceDecl, AstConstructionError>
Construct one occurrence with category-free named bindings.
§Errors
Rejects malformed names, expressions, and ranges.
pub fn named_binding(
name: impl Into<String>,
value: Expr,
range: TextRange,
) -> Result<NamedBindingDecl, AstConstructionError>
pub fn named_binding( name: impl Into<String>, value: Expr, range: TextRange, ) -> Result<NamedBindingDecl, AstConstructionError>
Construct one target-directed named binding.
§Errors
Rejects malformed names, expressions, and ranges.
pub fn expression(
kind: ExprKind,
range: TextRange,
) -> Result<Expr, AstConstructionError>
pub fn expression( kind: ExprKind, range: TextRange, ) -> Result<Expr, AstConstructionError>
Construct one source expression from an owned recursive expression kind.
§Errors
Returns an error for malformed names, non-finite literals, child expressions, or byte ranges.
Trait Implementations§
§impl Clone for SourceAstFactory
impl Clone for SourceAstFactory
§impl Debug for SourceAstFactory
impl Debug for SourceAstFactory
§impl Default for SourceAstFactory
impl Default for SourceAstFactory
§fn default() -> SourceAstFactory
fn default() -> SourceAstFactory
impl Copy for SourceAstFactory
Auto Trait Implementations§
impl Freeze for SourceAstFactory
impl RefUnwindSafe for SourceAstFactory
impl Send for SourceAstFactory
impl Sync for SourceAstFactory
impl Unpin for SourceAstFactory
impl UnsafeUnpin for SourceAstFactory
impl UnwindSafe for SourceAstFactory
Blanket Implementations§
Source§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Source§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§fn approx(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
§fn into_as<Dst>(self) -> Dstwhere
Self: Sized + Into<Dst>,
fn into_as<Dst>(self) -> Dstwhere
Self: Sized + Into<Dst>,
§fn try_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + TryInto<Dst>,
fn try_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + TryInto<Dst>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> From<T> for T
impl<T> From<T> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Same for T
impl<T> Same for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.