1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! 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_model`] and [`parse_module`] for turning DSL source text into the
//! syntax tree in [`ast`].
//! - [`analyze_model`] and [`analyze_module`] for semantic validation and the
//! typed IR in [`ir`].
//! - [`lower_typed_model`] and [`lower_typed_module`] for lowering typed models
//! into the execution representation in [`execution`].
//!
//! The frontend pipeline is intentionally simple:
//!
//! 1. Parse source text into syntax.
//! 2. Analyze the syntax into a typed model.
//! 3. Lower the typed model into an [`ExecutionModel`] or [`ExecutionModule`].
//!
//! 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:
//!
//! - [`ast`] for syntax-level nodes.
//! - [`diagnostic`] for spans, diagnostic codes, and rendered reports.
//! - [`ir`] for the typed intermediate representation.
//! - [`execution`] for the lowered execution model shared by JIT, AoT, and
//! WASM backends.
//!
//! Smallest parse-analyze-lower example:
//!
//! ```rust
//! 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.
/// Canonical prefix for numeric route labels such as `input_1`.
pub const NUMERIC_ROUTE_PREFIX: &str = "input_";
/// Canonical prefix for numeric output labels such as `outeq_1`.
pub const NUMERIC_OUTPUT_PREFIX: &str = "outeq_";
pub const RATE_FUNCTION_NAME: &str = "rate";
pub use *;
pub use *;
pub use ;
pub use *;
pub use ;
pub use ;