Skip to main content

pflow_dsl/
ast.rs

1//! AST types for the S-expression DSL.
2
3/// A parsed schema definition.
4#[derive(Debug, Clone)]
5pub struct SchemaNode {
6    pub name: String,
7    pub version: String,
8    pub states: Vec<StateNode>,
9    pub actions: Vec<ActionNode>,
10    pub arcs: Vec<ArcNode>,
11    pub constraints: Vec<ConstraintNode>,
12}
13
14/// A parsed state definition.
15#[derive(Debug, Clone)]
16pub struct StateNode {
17    pub id: String,
18    pub typ: String,
19    pub kind: String, // "token" or "data"
20    pub initial: Option<InitialValue>,
21    pub exported: bool,
22}
23
24/// Initial value for a state.
25#[derive(Debug, Clone)]
26pub enum InitialValue {
27    Int(i64),
28    Str(String),
29    Nil,
30}
31
32/// A parsed action definition.
33#[derive(Debug, Clone)]
34pub struct ActionNode {
35    pub id: String,
36    pub guard: String,
37}
38
39/// A parsed arc definition.
40#[derive(Debug, Clone)]
41pub struct ArcNode {
42    pub source: String,
43    pub target: String,
44    pub keys: Vec<String>,
45    pub value: String,
46}
47
48/// A parsed constraint definition.
49#[derive(Debug, Clone)]
50pub struct ConstraintNode {
51    pub id: String,
52    pub expr: String,
53}