scdlang 0.2.1

Core parser of Statecharts Description Languange
Documentation
//! Module that contain semantics graph of Scdlang which modeled as [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)
#![allow(dead_code)]

#[derive(Debug, Clone)]
/// SCXML equivalent:
/// ```scxml
/// <state id="from.name">
///     <transition target="to.name"/>
/// </state>
/// ```
pub struct Transition<'t> {
	pub from: State<'t>,
	pub to: State<'t>,
	pub at: Option<Event<'t>>,
	pub kind: TransitionType<'t>, // 🤔 maybe I should hide it then implement kind() method
}

#[derive(Debug, Clone)]
/// ```scl
/// state A {
/// 	B -> C // Internal(A)
/// }
/// A -> D // External
/// A <-> F // Duplex
/// A ->> L // Loop
/// ```
#[allow(clippy::large_enum_variant)]
pub enum TransitionType<'t> {
	Inside {
		state: &'t State<'t>,
		kind: &'t TransitionType<'t>,
	},
	Normal, // 🤔 should I implement Default trait?
	Toggle,
	Loop {
		transient: bool,
	},
}

#[derive(Debug, Clone)]
/// SCXML equivalent:
/// ```scxml
/// <state id="name"/>
/// ```
pub struct State<'s> {
	pub name: &'s str,
	pub kind: &'s StateType, // 🤔 should I hide it then implement kind() method?
}

#[derive(Debug)]
/// See https://statecharts.github.io/glossary/state.html
pub enum StateType {
	Atomic,
}

impl Into<String> for &State<'_> {
	fn into(self) -> String {
		self.name.to_string()
	}
}

#[derive(Debug, Clone)]
/// SCXML equivalent:
/// ```scxml
/// <transition event="name"/>
/// ```
pub struct Event<'s> {
	// pub kind: &'s EventType, // 🤔 probably should not be a field but more like kind() method because the type can be deduce on the available field
	pub name: &'s str, // TODO: should be None when it only have a Guard or it just an Internal Event
}

impl Into<String> for &Event<'_> {
	fn into(self) -> String {
		self.name.to_string()
	}
}

// 👇 still not sure 🤔
// #[derive(Debug)]
// /// see https://statecharts.github.io/glossary/internal-event.html
// pub enum EventType {
// 	External,
// }
// ☝️ maybe I need it if kind() method is exposed 🤔