Skip to content

Commit

Permalink
continu
Browse files Browse the repository at this point in the history
  • Loading branch information
nothendev committed Oct 17, 2023
1 parent df6f734 commit c5bdb04
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::{borrow::Cow, num::ParseIntError, ops::Range};
use oxcr_protocol::{
aott::{
self,
error::LabelError,
error::{BuiltinLabel, LabelError},
primitive::SeqLabel,
text::{self, CharError, CharLabel},
},
miette::{self, SourceSpan},
Expand Down Expand Up @@ -78,6 +79,14 @@ pub enum ParseError {
label: aott::error::BuiltinLabel,
last_token: Option<char>,
},

#[error("{label}; last token was {last_token:?}")]
Sequence {
#[label = "here"]
at: SourceSpan,
label: SeqLabel<char>,
last_token: Option<char>,
},
}

#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -123,4 +132,44 @@ impl<'a> aott::error::FundamentalError<&'a str> for ParseError {
}
}

impl<'a> LabelError<&'a str, CharLabel<char>> for ParseError {}
impl<'a> LabelError<&'a str, CharLabel<char>> for ParseError {
fn from_label(
span: Range<usize>,
label: CharLabel<char>,
last_token: Option<<&'a str as aott::prelude::InputType>::Token>,
) -> Self {
Self::Text {
at: span.into(),
label,
last_token,
}
}
}

impl<'a> LabelError<&'a str, BuiltinLabel> for ParseError {
fn from_label(
span: Range<usize>,
label: BuiltinLabel,
last_token: Option<<&'a str as aott::prelude::InputType>::Token>,
) -> Self {
Self::Builtin {
at: span.into(),
label,
last_token,
}
}
}

impl<'a> LabelError<&'a str, SeqLabel<char>> for ParseError {
fn from_label(
span: Range<usize>,
label: SeqLabel<char>,
last_token: Option<<&'a str as aott::prelude::InputType>::Token>,
) -> Self {
Self::Sequence {
at: span.into(),
label,
last_token,
}
}
}

0 comments on commit c5bdb04

Please sign in to comment.