pub trait Diagnostics {
// Provided methods
fn emit_unknown_content(&mut self, text: &str, span: Span) { ... }
fn emit_unexpected(
&mut self,
actual: &str,
expected: &[TokenType],
span: Span,
) { ... }
fn emit_parse_number_error(
&mut self,
value: &str,
error: ParseNumberError,
span: Span,
) { ... }
fn emit_parse_int_error(
&mut self,
value: &str,
_error: ParseIntError,
span: Span,
) { ... }
}Expand description
Callbacks invoked by the parser when it encounters invalid or unexpected input.
The parser does not abort on these conditions; it reports via your
implementation and continues. Override the default no-op implementations to
collect or log diagnostics. The crate module provides a
diagnostics type that implements this trait and accumulates messages.
Provided Methods§
Sourcefn emit_unknown_content(&mut self, text: &str, span: Span)
fn emit_unknown_content(&mut self, text: &str, span: Span)
Called when the parser sees text it cannot interpret (e.g. invalid tokens).
Sourcefn emit_unexpected(&mut self, actual: &str, expected: &[TokenType], span: Span)
fn emit_unexpected(&mut self, actual: &str, expected: &[TokenType], span: Span)
Called when the parser expected one of expected token types but found actual.
Sourcefn emit_parse_number_error(
&mut self,
value: &str,
error: ParseNumberError,
span: Span,
)
fn emit_parse_number_error( &mut self, value: &str, error: ParseNumberError, span: Span, )
Called when parsing a G/M/T number fails (e.g. overflow, invalid format).
Sourcefn emit_parse_int_error(
&mut self,
value: &str,
_error: ParseIntError,
span: Span,
)
fn emit_parse_int_error( &mut self, value: &str, _error: ParseIntError, span: Span, )
Called when parsing an N or O number fails (e.g. invalid integer, overflow).