pub struct Grammar<Term, NonTerm> {
pub rules: Vec<ProductionRule<Term, NonTerm>>,
/* private fields */
}Expand description
A struct for Context Free Grammar and DFA construction
Fields§
§rules: Vec<ProductionRule<Term, NonTerm>>set of production rules
Implementations§
source§impl<Term, NonTerm> Grammar<Term, NonTerm>
impl<Term, NonTerm> Grammar<Term, NonTerm>
pub fn new() -> Grammar<Term, NonTerm>
sourcepub fn add_rule(
&mut self,
name: NonTerm,
rule: Vec<Token<Term, NonTerm>>,
) -> usize
pub fn add_rule( &mut self, name: NonTerm, rule: Vec<Token<Term, NonTerm>>, ) -> usize
add new production rule for given nonterminal ‘name’
pub fn set_reduce_type( &mut self, term: Term, reduce_type: ReduceType, ) -> Result<(), BuildError<'static, Term, NonTerm>>
sourcepub fn build(
&mut self,
augmented_name: NonTerm,
) -> Result<Parser<Term, NonTerm>, BuildError<'_, Term, NonTerm>>
pub fn build( &mut self, augmented_name: NonTerm, ) -> Result<Parser<Term, NonTerm>, BuildError<'_, Term, NonTerm>>
build LR(1) parser table from given grammar
Trait Implementations§
Auto Trait Implementations§
impl<Term, NonTerm> Freeze for Grammar<Term, NonTerm>
impl<Term, NonTerm> RefUnwindSafe for Grammar<Term, NonTerm>where
NonTerm: RefUnwindSafe,
Term: RefUnwindSafe,
impl<Term, NonTerm> Send for Grammar<Term, NonTerm>
impl<Term, NonTerm> Sync for Grammar<Term, NonTerm>
impl<Term, NonTerm> Unpin for Grammar<Term, NonTerm>
impl<Term, NonTerm> UnwindSafe for Grammar<Term, NonTerm>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)