Expand description
Backend-neutral frontend crate for the pharmsol DSL.
Use this crate when you need the DSL frontend as an engineering API: parse model source, inspect diagnostics, analyze names and types, and lower a validated model into the execution representation that backends consume.
Do not use this crate when you already know you want JIT compilation,
native AoT artifacts, WASM artifacts, or Subject-based prediction
helpers. Those runtime-facing workflows stay in the main pharmsol crate
under pharmsol::dsl.
Main entrypoints:
parse_modelandparse_modulefor turning DSL source text into the syntax tree inast.analyze_modelandanalyze_modulefor semantic validation and the typed IR inir.lower_typed_modelandlower_typed_modulefor lowering typed models into the execution representation inexecution.
The frontend pipeline is intentionally simple:
- Parse source text into syntax.
- Analyze the syntax into a typed model.
- Lower the typed model into an
ExecutionModelorExecutionModule.
This crate accepts both canonical model { ... } source and the authoring
shorthand used by the pharmsol examples. The returned diagnostics carry
source spans, rendered messages, and structured data for editor or UI use.
Main modules:
astfor syntax-level nodes.diagnosticfor spans, diagnostic codes, and rendered reports.irfor the typed intermediate representation.executionfor the lowered execution model shared by JIT, AoT, and WASM backends.
Smallest parse-analyze-lower example:
use pharmsol_dsl::{analyze_model, lower_typed_model, parse_model};
let source = r#"
name = bimodal_ke
kind = ode
params = ke, v
states = central
outputs = cp
infusion(iv) -> central
dx(central) = -ke * central
out(cp) = central / v
"#;
let syntax = parse_model(source).expect("model parses");
let typed = analyze_model(&syntax).expect("model analyzes");
let execution = lower_typed_model(&typed).expect("model lowers");
assert_eq!(execution.name, "bimodal_ke");
assert_eq!(execution.metadata.routes.len(), 1);
assert_eq!(execution.metadata.outputs.len(), 1);If you are building an authoring tool, custom compiler, or diagnostics UI,
stay in this crate. If you want a complete source-to-runtime workflow,
switch to pharmsol::dsl in the main crate.
Re-exports§
pub use execution::lower_typed_model;pub use execution::lower_typed_module;pub use execution::ExecutionModel;pub use execution::ExecutionModule;pub use execution::LoweringError;pub use ast::*;pub use diagnostic::*;pub use ir::*;
Modules§
Structs§
Constants§
- NUMERIC_
OUTPUT_ PREFIX - Canonical prefix for numeric output labels such as
outeq_1. - NUMERIC_
ROUTE_ PREFIX - Canonical prefix for numeric route labels such as
input_1.