2021-04-18 15:33:55 -05:00
|
|
|
use std::ops::Range;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct Error {
|
|
|
|
pub kind: ErrorKind,
|
|
|
|
pub position: Range<usize>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub enum ErrorKind {
|
2021-04-26 03:44:42 -05:00
|
|
|
SyntaxError(String),
|
|
|
|
EndOfTokenStream,
|
2021-04-18 15:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Error {
|
|
|
|
pub fn panic(&self, span: &str) {
|
|
|
|
println!("{:?} occured at {:?}", self.kind, self.position);
|
|
|
|
println!(" {}", &span);
|
|
|
|
}
|
|
|
|
}
|