pub enum Combinator {
Show 19 variants
Rule(String),
Sequence(Vec<Combinator>),
Choice(Vec<Combinator>),
ZeroOrMore(Box<Combinator>),
OneOrMore(Box<Combinator>),
Optional(Box<Combinator>),
Skip(Box<Combinator>),
SeparatedBy {
item: Box<Combinator>,
separator: Box<Combinator>,
trailing: bool,
},
Pratt(PrattDef),
Mapped {
inner: Box<Combinator>,
mapping: String,
},
Literal(String),
Char(char),
CharClass(CharClass),
CharRange(char, char),
AnyChar,
NotFollowedBy(Box<Combinator>),
FollowedBy(Box<Combinator>),
Capture(Box<Combinator>),
Memoize {
id: usize,
inner: Box<Combinator>,
},
}Expand description
Parser combinators for scannerless parsing
Variants§
Rule(String)
Reference another rule by name
Sequence(Vec<Combinator>)
Sequence of combinators
Choice(Vec<Combinator>)
Ordered choice (first match wins, auto-backtrack)
ZeroOrMore(Box<Combinator>)
Zero or more
OneOrMore(Box<Combinator>)
One or more
Optional(Box<Combinator>)
Optional (zero or one)
Skip(Box<Combinator>)
Parse but discard result
SeparatedBy
Separated list: item (sep item)*
Pratt(PrattDef)
Pratt expression parsing
Mapped
AST mapping applied to inner combinator
Literal(String)
Match a literal string exactly (e.g., “if”, “===”, “+”)
Char(char)
Match a single character
CharClass(CharClass)
Match a character class (digit, alpha, etc.)
CharRange(char, char)
Match a character range (e.g., ‘a’..=‘z’)
AnyChar
Match any single character
NotFollowedBy(Box<Combinator>)
Negative lookahead (match if inner does NOT match, consume nothing)
FollowedBy(Box<Combinator>)
Positive lookahead (match if inner matches, consume nothing)
Capture(Box<Combinator>)
Capture the matched text as a string
Memoize
Memoize the result of parsing at each position to avoid exponential backtracking
Fields
inner: Box<Combinator>The inner combinator to memoize
Trait Implementations§
Source§impl Clone for Combinator
impl Clone for Combinator
Source§fn clone(&self) -> Combinator
fn clone(&self) -> Combinator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl CombinatorExt for Combinator
impl CombinatorExt for Combinator
Source§fn ast(self, mapping: TokenStream) -> Combinator
fn ast(self, mapping: TokenStream) -> Combinator
Apply AST mapping to this combinator