use std::path::PathBuf;
use crate::span::Span;
#[derive(Debug, Clone)]
pub struct Spanned<T> {
pub node: T,
pub span: Span,
}
impl<T> Spanned<T> {
pub fn new(node: T, span: Span) -> Self {
Self { node, span }
}
}
#[derive(Debug, Clone)]
pub struct Script {
pub commands: Vec<Spanned<Command>>,
}
#[derive(Debug, Clone)]
pub enum Command {
Log(LogCmd),
LogToggle {
enabled: bool,
},
Display(DisplayCmd),
Quote(String),
Assist(AssistSel),
View(PathBuf),
ViewLogToggle {
enabled: bool,
},
ProcedureOpen(PathBuf),
ProcedureClose,
ProcedureToggle {
enabled: bool,
},
XReadQuery,
XReadRaw(String),
Outgroup(OutgroupCmd),
Reroot,
CCode(CCodeCmd),
CKeep(u8),
CGet(u8),
Hennig {
multi: bool,
star: bool,
},
Bb {
star: bool,
},
Nelsen,
Ie,
IeStar,
IeDash,
Keep(u8),
Get(u8),
Files,
Erase(u8),
TXAscii(bool),
TPlot(Vec<TreeSelector>),
TRead {
title: Option<String>,
trees: Vec<String>,
},
TList(Vec<TreeSelector>),
TSave(PathBuf),
Tsvg {
tree: TreeSelector,
path: PathBuf,
},
NakedQuery,
NakedSet {
show_node_labels: bool,
},
TTags(TTagsCmd),
Resample(ResampleCmd),
OptCode(OptCodeCmd),
Apo {
tree: TreeSelector,
path: Option<PathBuf>,
},
TChoose(Vec<TreeSelector>),
XSteps(Vec<XStepsMode>),
Steps,
Watch(bool),
RSeed(RSeedCmd),
Bytes,
Yama,
XxQuery,
Batch(String),
Unknown {
name: String,
raw_args: String,
},
}
#[derive(Debug, Clone)]
pub enum ResampleCmd {
Boot {
replications: usize,
tree: TreeSelector,
search: Vec<ResampleSearchStep>,
},
Jak {
replications: usize,
tree: TreeSelector,
delete_percent: f64,
search: Vec<ResampleSearchStep>,
},
Sym {
replications: usize,
tree: TreeSelector,
delete_percent: f64,
search: Vec<ResampleSearchStep>,
},
}
#[derive(Debug, Clone, Copy)]
pub enum RSeedCmd {
Query,
Set(u64),
Random,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ResampleSearchStep {
Hennig { star: bool },
MHennig { star: bool },
Bb { star: bool },
Ie { star: bool, dash: bool },
}
#[derive(Debug, Clone)]
pub enum TTagsCmd {
Query,
Enable,
Clear,
WriteSvg(PathBuf),
SetLabel { node: usize, label: String },
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ApoOptimization {
Unambiguous,
Fast,
Slow,
}
#[derive(Debug, Clone)]
pub enum OptCodeCmd {
Query,
Apply(Vec<OptCodeOp>),
}
#[derive(Debug, Clone)]
pub struct OptCodeOp {
pub optimization: ApoOptimization,
pub chars: CharSel,
}
#[derive(Debug, Clone)]
pub enum AssistSel {
Default,
All,
Filter(String),
}
#[derive(Debug, Clone)]
pub enum LogCmd {
Start { path: PathBuf },
Stop,
}
#[derive(Debug, Clone)]
pub enum DisplayCmd {
ToTerminalAlso,
Disable,
}
#[derive(Debug, Clone)]
pub enum OutgroupCmd {
SetByNames(Vec<String>),
SetByNumbers(Vec<usize>),
Query,
}
#[derive(Debug, Clone)]
pub enum CCodeCmd {
Query,
Apply(Vec<CCodeOp>),
}
#[derive(Debug, Clone)]
pub enum CCodeOp {
Additive(CharSel),
NonAdditive(CharSel),
Active(CharSel),
Inactive(CharSel),
Weight(u32, CharSel),
}
#[derive(Debug, Clone)]
pub enum CharSel {
All,
List(Vec<CharRange>),
}
#[derive(Debug, Clone, Copy)]
pub enum CharRange {
Single(u32),
RangeInclusive(u32, u32),
}
#[derive(Debug, Clone)]
pub enum TreeSelector {
Index(usize),
RangeInclusive(usize, usize),
Last,
}
#[derive(Debug, Clone)]
pub enum XStepsMode {
L,
C,
H,
M,
W,
U,
}