use crate::{Expr, Op};
use smartstring::alias::String;
pub type Identifier = Vec<String>;
pub type Identifiers = Vec<Expr>;
pub type Block = Vec<Action>;
#[derive(Debug, PartialEq, PartialOrd, Clone)]
pub enum Action {
Comment(String),
VarAssign(Expr, Expr),
SingleShot(Expr, Op, Expr),
If(Vec<IfPart>),
FnCall(Expr, Identifiers),
FnDef(Expr, Identifier, Block),
Return(Option<Expr>),
Loop(Block),
Break,
Continue,
For(Identifier, Expr, Block),
While(Expr, Block),
Import(Expr, Option<Expr>),
}
#[derive(Debug, PartialEq, PartialOrd, Clone)]
pub enum IfPart {
If(Expr, Block),
IfElse(Expr, Block),
Else(Block),
}
impl Action {
pub fn to_expr(&self) -> Expr {
match self {
Action::FnCall(i, a) => Expr::FnCall(Box::new(i.to_owned()), a.to_owned()),
_ => unreachable!(),
}
}
}