use thiserror::Error;
use crate::lexing::Line;
#[derive(Debug, Error, Eq, PartialEq)]
pub enum LexError {
#[error("end of input reached")]
Eof,
#[error("failed to lex the string")]
Fail,
}
#[derive(Debug, Error, PartialEq, Eq)]
pub enum BaseParseError {
#[error("failed to parse dialog line")]
LexError(#[from] LexError),
#[error("sections must be at the start of the line")]
IndentedSectionStartError,
#[error("expected the start of a section but saw `{0}`")]
ExpectedSectionStart(Line<String, String, String>),
#[error("unexpected indent")]
UnexpectedIndent,
#[error("unexpected dedent")]
UnexpectedDedent,
#[error("expected line of type {0}, but found `{1}`")]
UnexpectedLine(&'static str, Line<String, String, String>),
#[error("expected a dialog node, but found `{0}`")]
NoDialogNodeFound(Line<String, String, String>),
#[error("expected dialog tree, but it was empty")]
EmptyDialogTree,
#[error("duplicate section name {0}")]
DuplicateSectionKey(String),
}
#[derive(Debug, Error, PartialEq, Eq)]
pub enum ParseError<DAError, IFError, TEError> {
#[error("{0}")]
Base(#[from] BaseParseError),
#[error("failed to parse do action: {0}")]
DoAction(DAError),
#[error("failed to parse if: {0}")]
IF(IFError),
#[error("failed to parse interpolation: {0}")]
TE(TEError),
}
#[derive(Debug, Error)]
pub enum SocraticError<DAError, IFError, TEError> {
#[error("encountered an error while parsing: {0}")]
Parse(#[from] ParseError<DAError, IFError, TEError>),
#[error("encountered an IO error: {0}")]
IO(#[from] std::io::Error),
}