1use std::ops::Range;
4
5use thiserror::Error;
6
7pub type ExprResult<T> = std::result::Result<T, Vec<(ExprError, Range<usize>)>>;
8
9#[derive(Debug, Error, PartialEq)]
10pub enum ExprError {
11 #[error("There was an error lexing expression: {0}")]
12 LexError(#[from] LexicalError),
13 #[error("There was a compliation error with the expression: {0}")]
14 CompileError(#[from] CompileError),
15}
16
17#[derive(Default, Debug, Clone, PartialEq, Error)]
18pub enum LexicalError {
19 #[default]
20 #[error("Invalid token")]
21 InvalidToken,
22}
23
24#[derive(Debug, Clone, PartialEq, Error)]
25pub enum CompileError {
26 #[error("undefined: {0}")]
27 Undefined(String),
28 #[error("expects {expected} arguments but received {actual}")]
29 WrongNumberOfArgs { expected: usize, actual: usize },
30}