pub trait ParserRule<'a, CustomTy = ()>{
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§
const ACTION: ParserRuleAction
Required Methods§
Sourcefn transform_token(&self, token: &mut Token<'_, CustomTy>) -> bool
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§
Sourcefn parse_custom<'b: 'a>(&mut self, _parser: &'b str) -> Token<'a, CustomTy>
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.
Sourcefn to_box(self) -> ParserRuleObjBox<'a, CustomTy>
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".