mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-14 16:45:07 +01:00
use dbg-pls for parser snapshot tests
This commit is contained in:
parent
31575cbdfb
commit
e7597dab07
7 changed files with 246 additions and 333 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use dbg_pls::{DebugPls, Formatter};
|
||||
use peekmore::PeekMoreIterator;
|
||||
|
||||
use crate::{
|
||||
|
|
@ -19,22 +20,28 @@ pub struct ParserError {
|
|||
}
|
||||
|
||||
impl ParserError {
|
||||
#[track_caller]
|
||||
fn new(span: Span, message: String) -> Self {
|
||||
Self { span, message }
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn eof() -> Self {
|
||||
Self::new(Span::default(), "unexpected end of file".to_string())
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn unsupported(span: Span, token: &Tok<'_>) -> Self {
|
||||
Self::new(span, format!("`{token}` is not supported"))
|
||||
}
|
||||
}
|
||||
|
||||
impl DebugPls for ParserError {
|
||||
fn fmt(&self, f: Formatter<'_>) {
|
||||
f.debug_struct("ParserError")
|
||||
.field("span", &self.span)
|
||||
.field("message", &self.message)
|
||||
.finish();
|
||||
}
|
||||
}
|
||||
|
||||
type Result<T, E = ParserError> = std::result::Result<T, E>;
|
||||
|
||||
struct Parser<'src, I>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue