[−][src]Struct cfgrammar::yacc::firsts::YaccFirsts
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>,
[src]
usize: AsPrimitive<StorageT>,
pub fn new(grm: &YaccGrammar<StorageT>) -> Self
[src]
Generates and returns the firsts set for the given grammar.
pub fn firsts(&self, ridx: RIdx<StorageT>) -> &Vob
[src]
Return all the firsts for rule ridx
.
pub fn is_set(&self, ridx: RIdx<StorageT>, tidx: TIdx<StorageT>) -> bool
[src]
Returns true if the token tidx
is in the first set for rule ridx
.
pub fn is_epsilon_set(&self, ridx: RIdx<StorageT>) -> bool
[src]
Returns true if the rule ridx
has epsilon in its first set.
pub fn set(&mut self, ridx: RIdx<StorageT>, tidx: TIdx<StorageT>) -> bool
[src]
Ensures that the firsts bit for token tidx
rule ridx
is set. Returns true if
it was already set, or false otherwise.
Trait Implementations
impl<StorageT: Debug> Debug for YaccFirsts<StorageT>
[src]
Auto Trait Implementations
impl<StorageT> RefUnwindSafe for YaccFirsts<StorageT> where
StorageT: RefUnwindSafe,
StorageT: RefUnwindSafe,
impl<StorageT> Send for YaccFirsts<StorageT> where
StorageT: Send,
StorageT: Send,
impl<StorageT> Sync for YaccFirsts<StorageT> where
StorageT: Sync,
StorageT: Sync,
impl<StorageT> Unpin for YaccFirsts<StorageT> where
StorageT: Unpin,
StorageT: Unpin,
impl<StorageT> UnwindSafe for YaccFirsts<StorageT> where
StorageT: UnwindSafe,
StorageT: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,