Struct perplex::grammar::Grammar [−][src]
pub struct Grammar { /* fields omitted */ }
A grammar.
Methods
impl Grammar
[src]
impl Grammar
pub fn new() -> Grammar
[src]
pub fn new() -> Grammar
Create a new empty grammar.
pub fn add_nonterminal<S: Into<String>>(&mut self, name: S) -> NonterminalId
[src]
pub fn add_nonterminal<S: Into<String>>(&mut self, name: S) -> NonterminalId
Add a nonterminal.
pub fn add_terminal<S: Into<String>>(&mut self, name: S) -> TerminalId
[src]
pub fn add_terminal<S: Into<String>>(&mut self, name: S) -> TerminalId
Add a terminal.
pub fn nonterminal<S: AsRef<str>>(&self, name: S) -> NonterminalId
[src]
pub fn nonterminal<S: AsRef<str>>(&self, name: S) -> NonterminalId
Lookup a nonterminal by name.
Panics if the nonterminal does not exist.
pub fn terminal<S: AsRef<str>>(&self, name: S) -> TerminalId
[src]
pub fn terminal<S: AsRef<str>>(&self, name: S) -> TerminalId
Lookup a terminal by name.
Panics if the terminal does not exist.
pub fn get_nonterminal<S: AsRef<str>>(&self, name: S) -> Option<NonterminalId>
[src]
pub fn get_nonterminal<S: AsRef<str>>(&self, name: S) -> Option<NonterminalId>
Find a nonterminal.
pub fn get_terminal<S: AsRef<str>>(&self, name: S) -> Option<TerminalId>
[src]
pub fn get_terminal<S: AsRef<str>>(&self, name: S) -> Option<TerminalId>
Find a terminal.
pub fn nonterminal_name(&self, id: NonterminalId) -> &str
[src]
pub fn nonterminal_name(&self, id: NonterminalId) -> &str
Get the name of a nonterminal.
pub fn terminal_name(&self, id: TerminalId) -> &str
[src]
pub fn terminal_name(&self, id: TerminalId) -> &str
Get the name of a terminal.
pub fn nonterminal_id_bound(&self) -> usize
[src]
pub fn nonterminal_id_bound(&self) -> usize
The upper bound on nonterminal IDs.
Basically returns the largest nonterminal ID + 1. Can be used as capacity for containers that will hold terminals.
pub fn terminal_id_bound(&self) -> usize
[src]
pub fn terminal_id_bound(&self) -> usize
The upper bound on terminal IDs.
Basically returns the largest terminal ID + 1. Can be used as capacity for containers that will hold terminals.
pub fn add_rule(&mut self, rule: Rule) -> RuleId
[src]
pub fn add_rule(&mut self, rule: Rule) -> RuleId
Add a rule to the grammar.
pub fn rules(&self) -> RulesIter
[src]
pub fn rules(&self) -> RulesIter
The rules in this grammar.
pub fn rules_for_nonterminal(&self, id: NonterminalId) -> RuleIdsIter
[src]
pub fn rules_for_nonterminal(&self, id: NonterminalId) -> RuleIdsIter
The rules for a specific nonterminal in the grammar.
pub fn rule(&self, id: RuleId) -> &Rule
[src]
pub fn rule(&self, id: RuleId) -> &Rule
Access a single rule of this grammar.
Panics if the id is the builtin ACCEPT
nonterminal, which represents
the virtual root rule.
Trait Implementations
impl Debug for Grammar
[src]
impl Debug for Grammar
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Grammar
[src]
impl Clone for Grammar
fn clone(&self) -> Grammar
[src]
fn clone(&self) -> Grammar
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Index<RuleId> for Grammar
[src]
impl Index<RuleId> for Grammar
type Output = Rule
The returned type after indexing.
fn index(&self, index: RuleId) -> &Rule
[src]
fn index(&self, index: RuleId) -> &Rule
Performs the indexing (container[index]
) operation.
impl IndexMut<RuleId> for Grammar
[src]
impl IndexMut<RuleId> for Grammar