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§
Sourcefn la(&mut self, offset: isize) -> i64
fn la(&mut self, offset: isize) -> i64
Token type (parser) or character (lexer) at the given lookahead.
Sourcefn token_text(&mut self, offset: isize) -> Option<&str>
fn token_text(&mut self, offset: isize) -> Option<&str>
Text of the token at the given lookahead, if present.
Sourcefn token_index_adjacent(&mut self) -> bool
fn token_index_adjacent(&mut self) -> bool
Whether LT(-2) and LT(-1) are adjacent token-stream entries.
Sourcefn ctx_rule_text(&self, rule_index: usize) -> Option<String>
fn ctx_rule_text(&self, rule_index: usize) -> Option<String>
Text of the current context’s first child with this rule index.
Sourcefn token_start_column(&self) -> Option<i64>
fn token_start_column(&self) -> Option<i64>
Lexer character position of the current token’s start.
Sourcefn token_text_so_far(&self) -> Option<String>
fn token_text_so_far(&self) -> Option<String>
Lexer text matched so far for the in-progress token.
Provided Methods§
Sourcefn trace_bool(&mut self, value: bool) -> bool
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".