use crate::span::Span;
#[derive(Debug, PartialEq, Eq)]
pub enum Ast {
Root(Root),
Condition(Condition),
Action(Action),
ActionDescription(Description),
}
impl Ast {
#[must_use]
pub fn span(&self) -> &Span {
match self {
Self::Root(x) => &x.span,
Self::Condition(x) => &x.span,
Self::Action(x) => &x.span,
Self::ActionDescription(x) => &x.span,
}
}
#[must_use]
pub fn is_action(&self) -> bool {
matches!(self, Self::Action(_))
}
}
#[derive(Debug, PartialEq, Eq)]
pub struct Root {
pub contract_name: String,
pub span: Span,
pub children: Vec<Ast>,
}
#[derive(Debug, PartialEq, Eq)]
pub struct Condition {
pub title: String,
pub span: Span,
pub children: Vec<Ast>,
}
#[derive(Debug, PartialEq, Eq)]
pub struct Action {
pub title: String,
pub span: Span,
pub children: Vec<Ast>,
}
#[derive(Debug, PartialEq, Eq)]
pub struct Description {
pub text: String,
pub span: Span,
}