Struct cfgrammar::yacc::ast::GrammarAST
source · pub struct GrammarAST {Show 14 fields
pub start: Option<(String, Span)>,
pub rules: IndexMap<String, Rule>,
pub prods: Vec<Production>,
pub tokens: IndexSet<String>,
pub spans: Vec<Span>,
pub precs: HashMap<String, (Precedence, Span)>,
pub avoid_insert: Option<HashMap<String, Span>>,
pub implicit_tokens: Option<HashMap<String, Span>>,
pub epp: HashMap<String, (Span, (String, Span))>,
pub expect: Option<(usize, Span)>,
pub expectrr: Option<(usize, Span)>,
pub parse_param: Option<(String, String)>,
pub programs: Option<String>,
pub expect_unused: Vec<Symbol>,
}
Expand description
An AST representing a grammar. This is built up gradually: when it is finished, the
complete_and_validate
must be called exactly once in order to finish the set-up. At that
point, any further mutations made to the struct lead to undefined behaviour.
Fields§
§start: Option<(String, Span)>
§rules: IndexMap<String, Rule>
§prods: Vec<Production>
§tokens: IndexSet<String>
§spans: Vec<Span>
§precs: HashMap<String, (Precedence, Span)>
§avoid_insert: Option<HashMap<String, Span>>
§implicit_tokens: Option<HashMap<String, Span>>
§epp: HashMap<String, (Span, (String, Span))>
§expect: Option<(usize, Span)>
§expectrr: Option<(usize, Span)>
§parse_param: Option<(String, String)>
§programs: Option<String>
§expect_unused: Vec<Symbol>
Implementations§
source§impl GrammarAST
impl GrammarAST
pub fn new() -> GrammarAST
pub fn add_rule( &mut self, (name, name_span): (String, Span), actiont: Option<String> )
pub fn add_prod( &mut self, rule_name: String, symbols: Vec<Symbol>, precedence: Option<String>, action: Option<String> )
pub fn add_programs(&mut self, s: String)
👎Deprecated since 0.10.2: Please use set_programs instead
pub fn set_programs(&mut self, s: String)
pub fn get_rule(&self, key: &str) -> Option<&Rule>
pub fn has_token(&self, s: &str) -> bool
pub fn warnings(&self) -> Vec<YaccGrammarWarning>
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for GrammarAST
impl Send for GrammarAST
impl Sync for GrammarAST
impl Unpin for GrammarAST
impl UnwindSafe for GrammarAST
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