Trait pest::Parser
[−]
[src]
pub trait Parser { type Rules; fn matches(&mut self, string: &str) -> bool; fn between(&mut self, left: char, right: char) -> bool; fn try<F>(&mut self, revert: bool, rule: F) -> bool where F: FnOnce(&mut Self) -> bool; fn pos(&self) -> usize; fn set_pos(&mut self, pos: usize); fn end(&self) -> bool; fn reset(&mut self); fn queue(&mut self) -> &mut VecDeque<Self::Rules>; fn skip_ws(&mut self); }
A trait
that defines a parser.
Associated Types
type Rules
Required Methods
fn matches(&mut self, string: &str) -> bool
Matches string
, returns whether it matched, and advances a parser with string.len()
in
case it did.
fn between(&mut self, left: char, right: char) -> bool
Matches char
between left
and right
, and advances a parser with one char
in case
it did.
fn try<F>(&mut self, revert: bool, rule: F) -> bool where F: FnOnce(&mut Self) -> bool
Tries to match rule
, returns whether it matched, and advances a parser with in case it
did. If revert
is true
, the parser will not advance.
fn pos(&self) -> usize
Returns the current position of a Parser
.
fn set_pos(&mut self, pos: usize)
Sets the position of a Parser
.
fn end(&self) -> bool
Returns whether a Parser
has reached it end.
fn reset(&mut self)
Reset a Parser
.
fn queue(&mut self) -> &mut VecDeque<Self::Rules>
Returns the queue of all matched Rules
.
fn skip_ws(&mut self)
Skips white-space.