Implement proper errors for expression evaluation
... the hard way
This commit is contained in:
parent
efa9b7de03
commit
5ee70bd769
4 changed files with 186 additions and 75 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue