tamer: parse::error: Describe unexpected token of input
When Parser has a unhandled dead state and fails due to an unexpected token of input, we should display what we interpreted that token as. DEV-7145main
parent
18803ea576
commit
0edb21429d
|
@ -22,6 +22,7 @@
|
|||
use super::Token;
|
||||
use crate::{
|
||||
diagnose::{Annotate, AnnotatedSpan, Diagnostic},
|
||||
fmt::{DisplayWrapper, TtQuote},
|
||||
span::Span,
|
||||
};
|
||||
use std::{error::Error, fmt::Display};
|
||||
|
@ -122,8 +123,8 @@ impl<T: Token, E: Diagnostic + PartialEq> Display for ParseError<T, E> {
|
|||
Self::UnexpectedEof(_, desc) => {
|
||||
write!(f, "unexpected end of input while {desc}")
|
||||
}
|
||||
Self::UnexpectedToken(_, desc) => {
|
||||
write!(f, "unexpected input while {desc}")
|
||||
Self::UnexpectedToken(tok, desc) => {
|
||||
write!(f, "unexpected {} while {desc}", TtQuote::wrap(tok))
|
||||
}
|
||||
// This is not really something the user should have to deal
|
||||
// with,
|
||||
|
|
Loading…
Reference in New Issue