diff --git a/src/database.rs b/src/database.rs index dd72b5a..1c1b0d4 100644 --- a/src/database.rs +++ b/src/database.rs @@ -104,6 +104,7 @@ use crate::diag::DiagnosticClass; use crate::export; use crate::formula::Formula; use crate::formula::Label; +use crate::formula::TypeCode; use crate::grammar; use crate::grammar::Grammar; use crate::grammar::StmtParse; @@ -781,6 +782,15 @@ impl Database { ) } + /// Returns the typecode for a given label. + #[must_use] + pub fn label_typecode(&self, label: Label) -> TypeCode { + let sref = self + .statement_by_label(label) + .expect("Invalid label provided to `label_typecode`."); + self.name_result().get_atom(sref.math_at(0).slice) + } + /// Export an mmp file for a given statement. /// Requires: [`Database::name_pass`], [`Database::scope_pass`] pub fn export(&self, stmt: &str) { diff --git a/src/formula.rs b/src/formula.rs index 92aedff..3bfb5a2 100644 --- a/src/formula.rs +++ b/src/formula.rs @@ -49,10 +49,16 @@ pub type Symbol = Atom; /// An atom representing a label (nameck suggests `LAtom` for this) pub type Label = Atom; -#[derive(Clone, Default)] +/// An error occurring during unification +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum UnificationError { + /// Generic unification failure + UnificationFailed, +} + /// A set of substitutions, mapping variables to a formula /// We also could have used `dyn Index<&Label, Output=Box>` -#[derive(Debug)] +#[derive(Clone, Debug, Default)] pub struct Substitutions(HashMap); impl Index