pub struct Parser<'a, I: Iterator<Item = Cursor> + Clone> { /* private fields */ }Implementations§
Source§impl<'a, I> Parser<'a, I>
impl<'a, I> Parser<'a, I>
Sourcepub const MAX_SUBSTITUTION_DEPTH: u8 = 32
pub const MAX_SUBSTITUTION_DEPTH: u8 = 32
Maximum nesting depth of substitution functions before parsing bails to Unresolved.
Sourcepub fn new(alloc: &'a Arena, source_text: &'a str, cursor_iter: I) -> Self
pub fn new(alloc: &'a Arena, source_text: &'a str, cursor_iter: I) -> Self
Create a new parser with an iterator over cursors
pub fn with_features(self, features: Feature) -> Self
pub fn alloc(&self) -> &'a Arena
Sourcepub fn enter_substitution(&mut self) -> bool
pub fn enter_substitution(&mut self) -> bool
Enters a substitution-function parse scope, incrementing the depth counter.
Returns false if the depth limit (Self::MAX_SUBSTITUTION_DEPTH) would be exceeded;
callers should then consume the tokens as an unresolved token sequence instead of recursing.
On success, callers MUST call Self::exit_substitution once parsing of the scope ends.
Sourcepub fn exit_substitution(&mut self)
pub fn exit_substitution(&mut self)
Exits a substitution-function parse scope, decrementing the depth counter.
pub fn enabled(&self, other: Feature) -> bool
Sourcepub fn source_text(&self) -> &'a str
pub fn source_text(&self) -> &'a str
The full source text the parser is reading from.
pub fn is(&self, state: State) -> bool
pub fn set_state(&mut self, state: State) -> State
pub fn set_skip(&mut self, skip: KindSet) -> KindSet
pub fn set_stop(&mut self, stop: KindSet) -> KindSet
pub fn parse_entirely<T: Parse<'a> + ToCursors>( &mut self, ) -> ParserReturn<'a, T>
pub fn parse<T: Parse<'a>>(&mut self) -> Result<T>
pub fn peek<T: Peek<'a>>(&self) -> bool
pub fn parse_if_peek<T: Peek<'a> + Parse<'a>>(&mut self) -> Result<Option<T>>
pub fn try_parse<T: Parse<'a>>(&mut self) -> Result<T>
pub fn try_parse_if_peek<T: Peek<'a> + Parse<'a>>( &mut self, ) -> Result<Option<T>>
pub fn equals_atom(&self, c: Cursor, atom: &'static dyn DynAtomSet) -> bool
pub fn to_atom<A: AtomSet + PartialEq>(&self, c: Cursor) -> A
pub fn offset(&self) -> SourceOffset
pub fn at_end(&self) -> bool
pub fn rewind(&mut self, checkpoint: ParserCheckpoint<I>)
pub fn checkpoint(&self) -> ParserCheckpoint<I>
pub fn next_is_stop(&self) -> bool
pub fn peek_n(&self, n: u8) -> Cursor
pub fn peek_n_including_whitespace(&self, n: u8) -> Cursor
pub fn to_source_cursor(&self, cursor: Cursor) -> SourceCursor<'a>
pub fn consume_trivia(&mut self) -> Vec<'a, Cursor>
Sourcepub fn consume_trivia_as_leading(&mut self)
pub fn consume_trivia_as_leading(&mut self)
Consume trivia and attach it to the next content token for output preservation. This should be called when you want to consume whitespace/comments but preserve them for round-trip output fidelity.