use std::fmt; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Position { At(usize), End, } impl fmt::Display for Position { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Position::At(index) => write!(f, "on position {}", index), Position::End => write!(f, "at the end"), } } } pub trait Error: std::error::Error { fn open_parenthesis_expected(position: Position) -> Self; fn close_parenthesis_expected(position: Position) -> Self; fn close_parenthesis_unexpected(position: Position) -> Self; fn lambda_expected(position: Position) -> Self; fn dot_expected(position: Position) -> Self; fn dot_unexpected(position: Position) -> Self; fn token_unexpected(position: Position) -> Self; fn parameter_expected(position: Position) -> Self; fn end_expected(position: Position) -> Self; fn end_unexpected(position: Position) -> Self; fn unbound_variable(identifier: String, position: Position) -> Self; fn no_expression(position: Position) -> Self; }