use crate::syntax::ast::{Command, Operand, Query};
use crate::value::Value;
pub(crate) enum MacroBinding {
One(Operand),
Rest(Vec<Operand>),
}
pub(crate) struct RegUsage {
pub(crate) pushes: std::collections::BTreeMap<String, usize>,
pub(crate) recalls: std::collections::BTreeMap<String, usize>,
}
pub(crate) trait Expander {
fn unit_scale(&self, expr: &str) -> Option<(f64, String)> {
crate::value::quantity::scale_expr(expr)
}
fn unit_names(&self) -> Option<Vec<String>> {
None
}
fn usage_of_query(&self, q: &Query) -> RegUsage;
fn usage_of_operand(&self, op: &Operand) -> RegUsage;
fn usage_of_commands(&self, commands: &[Command]) -> RegUsage;
fn operand_invites(&self, op: &Operand) -> std::collections::BTreeSet<String>;
fn expand(
&self,
name: &str,
body: &Query,
bindings: &[(String, MacroBinding)],
data_aware: bool,
) -> crate::Result<Vec<Value>>;
}