Parser

Trait Parser 

Source
pub trait Parser<'a, T>
where T: Input<'a>,
{ type Rule; type Token;
Show 19 methods // Required methods fn input(&self) -> &T; fn input_mut(&mut self) -> &mut T; fn end(&self) -> bool; fn eoi_matched(&self) -> bool; fn reset(&mut self); fn queue(&self) -> &Vec<Self::Token>; fn queue_mut(&mut self) -> &mut Vec<Self::Token>; fn queue_with_captures(&self) -> Vec<(Self::Token, String)>; fn queue_index(&self) -> usize; fn inc_queue_index(&self); fn set_queue_index(&self, index: usize); fn skip(&mut self); fn is_atomic(&self) -> bool; fn set_atomic(&mut self, value: bool); fn track(&mut self, failed: Self::Rule, pos: usize); fn tracked_len_pos(&self) -> (usize, usize); fn expected(&mut self) -> (Vec<Self::Rule>, usize); fn stack(&self) -> &Vec<String>; fn stack_mut(&mut self) -> &mut Vec<String>;
}
Expand description

A trait that defines a parser.

Required Associated Types§

Required Methods§

Source

fn input(&self) -> &T

Source

fn input_mut(&mut self) -> &mut T

Source

fn end(&self) -> bool

Returns whether a Parser has reached its end.

Source

fn eoi_matched(&self) -> bool

Returns whether a Parser has matched end-of-input.

Source

fn reset(&mut self)

Reset a Parser.

Source

fn queue(&self) -> &Vec<Self::Token>

Returns the queue of all matched Tokens.

Source

fn queue_mut(&mut self) -> &mut Vec<Self::Token>

Returns the mutable queue of all matched Tokens.

Source

fn queue_with_captures(&self) -> Vec<(Self::Token, String)>

Returns the queue of all matched (Token, value)s.

Source

fn queue_index(&self) -> usize

Returns the current index within the queue. Used in process!.

Source

fn inc_queue_index(&self)

Increments the current index within the queue. Used in process!.

Source

fn set_queue_index(&self, index: usize)

Set the current index within the queue. Used in process!.

Source

fn skip(&mut self)

Skips whitespace and comments.

Source

fn is_atomic(&self) -> bool

Returns whether a Parser is currently inside an atomic rule.

Source

fn set_atomic(&mut self, value: bool)

Sets a Parser to atomic rule mode, barring comment & white-space skipping.

Source

fn track(&mut self, failed: Self::Rule, pos: usize)

Keeps track of rule failures. It gets called when a Rule fails at pos.

Source

fn tracked_len_pos(&self) -> (usize, usize)

Returns the length of the tracked Rules.

Source

fn expected(&mut self) -> (Vec<Self::Rule>, usize)

Retuns a Vec of all expected Rules at the deepest position where the parsing last stopped. It only returns leafs from the rule tree. Used for error reporting.

Source

fn stack(&self) -> &Vec<String>

Returns the stack Vec.

Source

fn stack_mut(&mut self) -> &mut Vec<String>

Returns the mutable stack Vec.

Implementors§

Source§

impl<'input, T: Input<'input>> Parser<'input, T> for Rdp<T>

Source§

type Rule = Rule

Source§

type Token = Token<Rule>