Struct parol::grammar::production::Pr
source · pub struct Pr(pub Symbol, pub Rhs, pub ProductionAttribute);
Expand description
Production type
Tuple Fields§
§0: Symbol
§1: Rhs
§2: ProductionAttribute
Implementations§
Trait Implementations§
source§impl Display for Pr
impl Display for Pr
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
The output format for a production roughly follows the Yacc format.
use parol::{Pr, Symbol, SymbolAttribute, Terminal, TerminalKind};
macro_rules! terminal {
($term:literal) => {Symbol::T(Terminal::Trm($term.to_string(), TerminalKind::Legacy,
vec![0], SymbolAttribute::None, None))};
}
let pr = Pr::new("S", vec![]);
assert_eq!("S: ;", format!("{}", pr));
let pr = Pr::new("S", vec![Symbol::n("N"), Symbol::n("L")]);
assert_eq!("S: N L;", format!("{}", pr));
let pr = Pr::new("S", vec![Symbol::n("I"), Symbol::n("L")]);
assert_eq!("S: I L;", format!("{}", pr));
let pr = Pr::new("S", vec![terminal!(","), Symbol::n("N")]);
assert_eq!(r#"S: "," N;"#, format!("{}", pr));
let pr = Pr::new("S", vec![terminal!("d")]);
assert_eq!(r#"S: "d";"#, format!("{}", pr));
let pr = Pr::new("S", vec![terminal!(r#"[0-9]"#), terminal!("e")]);
assert_eq!(r#"S: "[0-9]" "e";"#, format!("{}", pr));
source§impl Ord for Pr
impl Ord for Pr
source§impl PartialOrd for Pr
impl PartialOrd for Pr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Pr
impl StructuralPartialEq for Pr
Auto Trait Implementations§
impl Freeze for Pr
impl RefUnwindSafe for Pr
impl Send for Pr
impl Sync for Pr
impl Unpin for Pr
impl UnwindSafe for Pr
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.