Skip to main content

PredContext

Trait PredContext 

Source
pub trait PredContext {
    // Required methods
    fn la(&mut self, offset: isize) -> i64;
    fn token_text(&mut self, offset: isize) -> Option<&str>;
    fn token_index_adjacent(&mut self) -> bool;
    fn ctx_rule_text(&self, rule_index: usize) -> Option<String>;
    fn member(&self, member: usize) -> Option<i64>;
    fn local_arg(&self) -> Option<i64>;
    fn column(&self) -> Option<i64>;
    fn token_start_column(&self) -> Option<i64>;
    fn token_text_so_far(&self) -> Option<String>;
    fn hook(&mut self, hook: HookId) -> bool;

    // Provided method
    fn trace_bool(&mut self, value: bool) -> bool { ... }
}
Expand description

Recognizer-state queries the predicate evaluator needs.

Implementations are thin adapters over a lexer or parser; queries that do not exist for the implementing recognizer return None (evaluating to Null). Lookahead methods take &mut self because token streams buffer lazily.

Required Methods§

Source

fn la(&mut self, offset: isize) -> i64

Token type (parser) or character (lexer) at the given lookahead.

Source

fn token_text(&mut self, offset: isize) -> Option<&str>

Text of the token at the given lookahead, if present.

Source

fn token_index_adjacent(&mut self) -> bool

Whether LT(-2) and LT(-1) are adjacent token-stream entries.

Source

fn ctx_rule_text(&self, rule_index: usize) -> Option<String>

Text of the current context’s first child with this rule index.

Source

fn member(&self, member: usize) -> Option<i64>

Integer member slot value.

Source

fn local_arg(&self) -> Option<i64>

Integer argument of the current rule invocation.

Source

fn column(&self) -> Option<i64>

Lexer current character position within the line.

Source

fn token_start_column(&self) -> Option<i64>

Lexer character position of the current token’s start.

Source

fn token_text_so_far(&self) -> Option<String>

Lexer text matched so far for the in-progress token.

Source

fn hook(&mut self, hook: HookId) -> bool

Evaluates an externally implemented predicate hook.

Provided Methods§

Source

fn trace_bool(&mut self, value: bool) -> bool

Reports an observable predicate-evaluation template and returns value.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§