#[non_exhaustive]pub struct GrammarAST {Show 15 fields
pub start: Option<(String, Span)>,
pub rules: IndexMap<String, Rule>,
pub prods: Vec<Production>,
pub token_directives: HashSet<usize>,
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 (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.start: Option<(String, Span)>
§rules: IndexMap<String, Rule>
§prods: Vec<Production>
§token_directives: HashSet<usize>
§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>, prod_span: Span, )
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§
Source§impl Clone for GrammarAST
impl Clone for GrammarAST
Source§fn clone(&self) -> GrammarAST
fn clone(&self) -> GrammarAST
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for GrammarAST
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