Skip to main content

ParserRule

Trait ParserRule 

Source
pub trait ParserRule<'a, CustomTy = ()>
where CustomTy: Clone + 'a, Self: Sized + Send + 'a,
{ const ACTION: ParserRuleAction; // Required method fn transform_token(&self, token: &mut Token<'_, CustomTy>) -> bool; // Provided methods fn parse_custom<'b: 'a>(&mut self, _parser: &'b str) -> Token<'a, CustomTy> { ... } fn to_box(self) -> ParserRuleObjBox<'a, CustomTy> { ... } }
Expand description

Provides the common API for parser rules, allowing the programmer to modify parsing behavior.

Required Associated Constants§

Required Methods§

Source

fn transform_token(&self, token: &mut Token<'_, CustomTy>) -> bool

Called whenever a new token has been produced, allowing the rule to transform a token. Upon returning false, the parser rule will be removed from the rule stack.

§Remarks

transform_token is always called before open/close tag tracking, as such the current set of open tags will not contain the tag given, and the transformer can emit open/close tags and expect them to be tracked correctly.

Provided Methods§

Source

fn parse_custom<'b: 'a>(&mut self, _parser: &'b str) -> Token<'a, CustomTy>

Provides a mechanism for custom parsing logic, should ParserRule::ACTION be ParserRuleAction::CustomParser. Will not be called otherwise.

Source

fn to_box(self) -> ParserRuleObjBox<'a, CustomTy>

Boxes the given rule into a ParserRuleObj.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, 'rule_life: 'a, CustomTy> ParserRule<'a, CustomTy> for NoParseRule<'rule_life, CustomTy>
where CustomTy: Clone + Send + 'a,

Source§

const ACTION: ParserRuleAction = ParserRuleAction::NoParse