pub trait TokenStream<T> {
// Required methods
fn peek(&mut self, offset: usize) -> Spanned<T>;
fn bump(&mut self);
fn consumed(&self) -> usize;
fn last_span(&self) -> Span;
fn emit(&mut self, diag: DiagBuilder2);
fn severity(&self) -> Severity;
// Provided methods
fn skip(&mut self) { ... }
fn last_loc(&self) -> Location { ... }
fn is_fatal(&self) -> bool { ... }
fn is_error(&self) -> bool { ... }
}
Expand description
A generalized stream of tokens that accepts emission of diagnostics and tracking of the severity of issues encountered.
Required Methods§
Sourcefn consumed(&self) -> usize
fn consumed(&self) -> usize
Get the number of tokens consumed. Excludes tokens skipped with skip
.
Sourcefn emit(&mut self, diag: DiagBuilder2)
fn emit(&mut self, diag: DiagBuilder2)
Emit a diagnostic.
Provided Methods§
Sourcefn skip(&mut self)
fn skip(&mut self)
Skip the current token. Usually the same as bump
, but may be used to
keep skipped tokens out of the consumed tokens count by some parsers.