pub struct AtomStream { /* private fields */ }Expand description
A parse source over an eagerly lexed token vector, which remembers how far the parse ever got and stops it if it goes on too long.
Backtracking runs through syan’s Tape, which owns the pushback and the
checkpoint scopes, so the forwarding half of this is a thin shim; the mark
and the budget are the parts that are not.
Implementations§
Source§impl AtomStream
impl AtomStream
Sourcepub fn new(atoms: Vec<Atom>) -> Self
pub fn new(atoms: Vec<Atom>) -> Self
Wrap an eagerly lexed atom vector, with the budget Budget
calibrates for its size.
Sourcepub fn with_budget(atoms: Vec<Atom>, budget: Budget) -> Self
pub fn with_budget(atoms: Vec<Atom>, budget: Budget) -> Self
Self::new with the budget chosen by the caller.
Sourcepub fn furthest(&self) -> usize
pub fn furthest(&self) -> usize
End byte of the furthest atom the parser ever consumed; 0 if it
consumed nothing.
Consumed, not peeked: a lookahead that rejects a token has not made progress through it, and counting it would push every diagnostic one token to the right.
Sourcepub fn furthest_span(&self) -> Option<Span>
pub fn furthest_span(&self) -> Option<Span>
The span of the atom that set Self::furthest — the token the parse
stopped at.
It is the token ending at the mark, not the one starting after it:
the generated leaf parsers are next() → match → push()-back-on-
mismatch (see crate::leaf), so the offending token has already been
pulled through the stream by the time the leaf rejects it. Reporting
the token after it would put every diagnostic one token to the right.
Sourcepub fn exhausted(&self) -> bool
pub fn exhausted(&self) -> bool
Whether the parse hit its budget rather than reaching a real verdict.
When this is true, the failure the parser reported means only “the
stream ended”, which is this type’s doing and not the source’s — so the
caller must not dress it up as a claim about the source.
crate::parse_error::locate does not.
Trait Implementations§
Source§impl ParseStream for AtomStream
impl ParseStream for AtomStream
Source§type Error = Infallible
type Error = Infallible
get_error.Source§fn next(&mut self) -> Option<Self::Atom>
fn next(&mut self) -> Option<Self::Atom>
None at end of input.Source§fn push(&mut self, atom: Self::Atom)
fn push(&mut self, atom: Self::Atom)
Source§fn checkpoint_raw(&mut self) -> u64
fn checkpoint_raw(&mut self) -> u64
Source§fn rollback_raw(&mut self, raw: u64)
fn rollback_raw(&mut self, raw: u64)
raw was taken, and close that scope.Source§fn commit_raw(&mut self, raw: u64)
fn commit_raw(&mut self, raw: u64)
raw was taken, and close that scope.Source§fn get_error(&mut self) -> Result<(), Self::Error>
fn get_error(&mut self) -> Result<(), Self::Error>
Ok(()) for a source that cannot fail.Source§fn skip_sep(&mut self) -> bool
fn skip_sep(&mut self) -> bool
Source§fn validate_spacing<S>(&mut self, is_joint: bool) -> Result<(), ParseError<S>>
fn validate_spacing<S>(&mut self, is_joint: bool) -> Result<(), ParseError<S>>
is_joint demands no separator here, false demands
one. Fails with ParseError::Spacing if the input
disagrees.