Trait gramatica::ParsingTablesTrait
source · pub trait ParsingTablesTrait<T> {
// Required methods
fn initial() -> usize;
fn match_some(parser: &mut Parser<'_, T, Self>) -> Option<(usize, T)>
where Self: Sized;
fn predict(
parser: &mut Parser<'_, T, Self>,
index: usize,
state_index: usize,
token: usize
)
where Self: Sized;
fn compute_value(state: &mut State<T>);
fn table_terminal(token_index: usize) -> bool;
fn table_priority(a: usize, b: usize) -> Option<Ordering>;
fn table_associativity(rule: usize) -> Option<Associativity>;
fn to_usize(token: &T) -> usize;
// Provided method
fn take_token(token: &mut T) -> T
where T: Clone + Default { ... }
}
Expand description
The functions defining the grammar to use.
Required Methods§
sourcefn match_some(parser: &mut Parser<'_, T, Self>) -> Option<(usize, T)>where
Self: Sized,
fn match_some(parser: &mut Parser<'_, T, Self>) -> Option<(usize, T)>where Self: Sized,
Extract a token.
sourcefn predict(
parser: &mut Parser<'_, T, Self>,
index: usize,
state_index: usize,
token: usize
)where
Self: Sized,
fn predict( parser: &mut Parser<'_, T, Self>, index: usize, state_index: usize, token: usize )where Self: Sized,
for each token->right in grammar, add the rule to self.sets[index]
sourcefn compute_value(state: &mut State<T>)
fn compute_value(state: &mut State<T>)
Compute the value of a state. Assumes all dependencies are already been computed.
sourcefn table_terminal(token_index: usize) -> bool
fn table_terminal(token_index: usize) -> bool
Says whether a token is a terminal token.
sourcefn table_associativity(rule: usize) -> Option<Associativity>
fn table_associativity(rule: usize) -> Option<Associativity>
Check whether we resolve ambiguity and how.
Provided Methods§
sourcefn take_token(token: &mut T) -> Twhere
T: Clone + Default,
fn take_token(token: &mut T) -> Twhere T: Clone + Default,
Clone a terminal and otherwise std::mem::take it.