Struct cfgrammar::yacc::firsts::YaccFirsts [−][src]
pub struct YaccFirsts<StorageT> { /* fields omitted */ }
Expand description
Firsts
stores all the first sets for a given grammar. For example, given this code and
grammar:
let grm = YaccGrammar::new(YaccKind::Original(YaccOriginalActionKind::GenericParseTree), " S: A 'b'; A: 'a' | ;").unwrap(); let firsts = Firsts::new(&grm);
then the following assertions (and only the following assertions) about the firsts set are correct:
assert!(firsts.is_set(grm.rule_idx("S").unwrap(), grm.token_idx("a").unwrap())); assert!(firsts.is_set(grm.rule_idx("S").unwrap(), grm.token_idx("b").unwrap())); assert!(firsts.is_set(grm.rule_idx("A").unwrap(), grm.token_idx("a").unwrap())); assert!(firsts.is_epsilon_set(grm.rule_idx("A").unwrap()));
Implementations
impl<StorageT: 'static + PrimInt + Unsigned> YaccFirsts<StorageT> where
usize: AsPrimitive<StorageT>,
impl<StorageT: 'static + PrimInt + Unsigned> YaccFirsts<StorageT> where
usize: AsPrimitive<StorageT>,
Generates and returns the firsts set for the given grammar.
Returns true if the token tidx
is in the first set for rule ridx
.
Returns true if the rule ridx
has epsilon in its first set.