pub struct CFG {
pub start: String,
pub productions: Vec<Production>,
pub non_terminals: Vec<String>,
pub terminals: Vec<String>,
}Expand description
A context-free grammar used as a syntax guide for synthesis.
Fields§
§start: StringStart symbol.
productions: Vec<Production>All production rules.
non_terminals: Vec<String>Non-terminal symbols.
terminals: Vec<String>Terminal symbols.
Implementations§
Source§impl CFG
impl CFG
Sourcepub fn new(start: impl Into<String>) -> Self
pub fn new(start: impl Into<String>) -> Self
Build a minimal CFG with one production from start.
Sourcepub fn add_production(&mut self, lhs: impl Into<String>, rhs: Vec<String>)
pub fn add_production(&mut self, lhs: impl Into<String>, rhs: Vec<String>)
Add a production rule.
Sourcepub fn add_terminal(&mut self, t: impl Into<String>)
pub fn add_terminal(&mut self, t: impl Into<String>)
Add a terminal symbol.
Sourcepub fn productions_for(&self, nt: &str) -> Vec<&Production>
pub fn productions_for(&self, nt: &str) -> Vec<&Production>
Count productions for a given non-terminal.
Trait Implementations§
impl Eq for CFG
impl StructuralPartialEq for CFG
Auto Trait Implementations§
impl Freeze for CFG
impl RefUnwindSafe for CFG
impl Send for CFG
impl Sync for CFG
impl Unpin for CFG
impl UnsafeUnpin for CFG
impl UnwindSafe for CFG
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