Implement proper errors for expression evaluation

... the hard way
This commit is contained in:
Joscha 2021-12-06 22:18:57 +01:00
parent efa9b7de03
commit 5ee70bd769
4 changed files with 186 additions and 75 deletions

View file

@ -1,4 +1,4 @@
use std::cmp::Ordering;
use std::cmp::{self, Ordering};
use std::fmt;
#[derive(Debug, Clone, Copy)]
@ -16,6 +16,15 @@ impl<'a> From<&pest::Span<'a>> for Span {
}
}
impl Span {
pub fn join(self, other: Self) -> Self {
Self {
start: cmp::min(self.start, other.start),
end: cmp::max(self.end, other.end),
}
}
}
#[derive(Clone, Copy)]
pub struct Spanned<T> {
pub span: Span,