Skip to main content

Tracker

Trait Tracker 

Source
pub(super) trait Tracker<'matcher> {
    // Required methods
    fn prepare(
        &mut self,
        which_matcher: WhichMatcher,
        matcher: &'matcher [MatcherLoc],
    );
    fn before_match_loc(
        &mut self,
        parser: &TtParser,
        matcher: &'matcher MatcherLoc,
    );
    fn matched_one(&mut self, parser: &Parser<'_>, loc_index: usize);
    fn after_arm(
        &mut self,
        result: &ParseResult<FxHashMap<MacroRulesNormalizedIdent, NamedMatch>>,
    );
    fn failure(&mut self, parser: &Parser<'_>);
    fn ambiguity(&mut self, parser: &Parser<'_>);
    fn description() -> &'static str;
    fn recovery() -> Recovery;
}

Required Methods§

Source

fn prepare( &mut self, which_matcher: WhichMatcher, matcher: &'matcher [MatcherLoc], )

Provide context on the arm that’s about to be matched.

Source

fn before_match_loc(&mut self, parser: &TtParser, matcher: &'matcher MatcherLoc)

This is called before trying to match next MatcherLoc on the current token.

Source

fn matched_one(&mut self, parser: &Parser<'_>, loc_index: usize)

A MatcherLoc successfully consumed input from the parser.

This is called for MatcherLoc::Token and MatcherLoc::SequenceSep, which consume single tokens, when they successfully match Parser::token. It is also called for MatcherLoc::MetaVarDecl when non-terminal parsing is guaranteed to occur (i.e. after Parser::nonterminal_may_begin_with() returns true).

Source

fn after_arm( &mut self, result: &ParseResult<FxHashMap<MacroRulesNormalizedIdent, NamedMatch>>, )

This is called after an arm has been parsed, either successfully or unsuccessfully. When this is called, before_match_loc was called at least once (with a MatcherLoc::Eof).

Source

fn failure(&mut self, parser: &Parser<'_>)

The arm could not be matched successfully.

If the parser is located at token::Eof, it indicates an unexpected end of macro invocation. Otherwise, the parser is located at a token in the middle of the input, and it indicates that no rules in the arm expected the given token.

The parser will return NamedParseResult::Failure after calling this.

Source

fn ambiguity(&mut self, parser: &Parser<'_>)

An ambiguity error occurred.

The parser will return NamedParseResult::Ambiguity after calling this.

Source

fn description() -> &'static str

For tracing.

Source

fn recovery() -> Recovery

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<'dcx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'dcx, 'matcher>

Source§

impl<'matcher> Tracker<'matcher> for NoopTracker