Trait Recognizer
pub trait Recognizer {
// Required methods
fn pop_bytes(&mut self, num: usize);
fn collapse(&mut self);
fn special_allowed(&mut self, tok: SpecialToken) -> bool;
fn trie_finished(&mut self);
fn try_push_byte(&mut self, byte: u8) -> bool;
// Provided methods
fn byte_allowed(&mut self, byte: u8) -> bool { ... }
fn trie_started(&mut self) { ... }
fn get_error(&mut self) -> Option<String> { ... }
}
Required Methods§
fn collapse(&mut self)
fn collapse(&mut self)
“Collapse” the stack so that it consists only of its former top element. X = stack.top(); stack.empty(); stack.push(X)
fn special_allowed(&mut self, tok: SpecialToken) -> bool
fn special_allowed(&mut self, tok: SpecialToken) -> bool
check if stack.top() transitions via tok to a viable state
fn trie_finished(&mut self)
fn trie_finished(&mut self)
Called when iteration over the trie is finished Stack has exactly one element then, except when iteration started from non-root node. In that case, the stack may have more than one element, and trie_finished() needs to pop the excessive elements.
fn try_push_byte(&mut self, byte: u8) -> bool
fn try_push_byte(&mut self, byte: u8) -> bool
This combines push_byte
and byte_allowed
into one function for performance.
Provided Methods§
fn byte_allowed(&mut self, byte: u8) -> bool
fn byte_allowed(&mut self, byte: u8) -> bool
check if stack.top() transitions via byte to a viable state
fn trie_started(&mut self)
fn trie_started(&mut self)
Called when iteration over the trie is started