pub struct Ll1Table {
pub table: HashMap<(usize, Option<usize>), usize>,
pub n_nonterms: usize,
pub n_terms: usize,
}Expand description
An LL(1) parsing table for a given grammar.
Fields§
§table: HashMap<(usize, Option<usize>), usize>For each (nonterminal, terminal) pair, the production index to use. The terminal None represents end-of-input.
n_nonterms: usizeNumber of nonterminals.
n_terms: usizeNumber of terminals.
Implementations§
Source§impl Ll1Table
impl Ll1Table
Sourcepub fn set(&mut self, nt: usize, term: Option<usize>, prod: usize)
pub fn set(&mut self, nt: usize, term: Option<usize>, prod: usize)
Set the production for (nonterminal, terminal).
Sourcepub fn get(&self, nt: usize, term: Option<usize>) -> Option<usize>
pub fn get(&self, nt: usize, term: Option<usize>) -> Option<usize>
Look up the production for (nonterminal, terminal).
Sourcepub fn is_conflict_free(&self) -> bool
pub fn is_conflict_free(&self) -> bool
Check if the table is conflict-free (no cell has more than one production). Since we use a HashMap, each cell has at most one entry by construction.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Count the number of filled table entries.
Sourcepub fn build(grammar: &ContextFreeGrammar, sets: &FirstFollowSets<'_>) -> Self
pub fn build(grammar: &ContextFreeGrammar, sets: &FirstFollowSets<'_>) -> Self
Build an LL(1) table from a grammar and its FIRST/FOLLOW sets.
Auto Trait Implementations§
impl Freeze for Ll1Table
impl RefUnwindSafe for Ll1Table
impl Send for Ll1Table
impl Sync for Ll1Table
impl Unpin for Ll1Table
impl UnsafeUnpin for Ll1Table
impl UnwindSafe for Ll1Table
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more