bug fixes and performance improvements

This commit is contained in:
2023-05-07 22:35:38 +01:00
parent f3ce910f66
commit a604e40bad
167 changed files with 5965 additions and 4229 deletions

View File

@@ -1,18 +1,36 @@
use std::{fmt, error::Error};
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
use crate::interner::{Token, InternedDisplay, Interner};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RuleError {
BadState(String),
ScalarVecMismatch(String)
Missing(Token<String>),
TypeMismatch(Token<String>),
/// Multiple occurences of a placeholder in a pattern are no longer
/// supported.
Multiple(Token<String>),
VecNeighbors(Token<String>, Token<String>),
}
impl fmt::Display for RuleError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::BadState(key) => write!(f, "Key {:?} not in match pattern", key),
Self::ScalarVecMismatch(key) =>
write!(f, "Key {:?} used inconsistently with and without ellipsis", key)
impl InternedDisplay for RuleError {
fn fmt_i(&self, f: &mut fmt::Formatter<'_>, i: &Interner) -> fmt::Result {
match *self {
Self::Missing(key) => write!(f,
"Key {:?} not in match pattern",
i.r(key)
),
Self::TypeMismatch(key) => write!(f,
"Key {:?} used inconsistently with and without ellipsis",
i.r(key)
),
Self::Multiple(key) => write!(f,
"Key {:?} appears multiple times in match pattern",
i.r(key)
),
Self::VecNeighbors(left, right) => write!(f,
"Keys {:?} and {:?} are two vectorials right next to each other",
i.r(left), i.r(right)
)
}
}
}
impl Error for RuleError {}
}