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

source

pub fn new() -> GrammarAST

source

pub fn add_rule( &mut self, (name, name_span): (String, Span), actiont: Option<String>, )

source

pub fn add_prod( &mut self, rule_name: String, symbols: Vec<Symbol>, precedence: Option<String>, action: Option<String>, )

source

pub fn add_programs(&mut self, s: String)

👎Deprecated since 0.10.2: Please use set_programs instead
source

pub fn set_programs(&mut self, s: String)

source

pub fn get_rule(&self, key: &str) -> Option<&Rule>

source

pub fn has_token(&self, s: &str) -> bool

source

pub fn warnings(&self) -> Vec<YaccGrammarWarning>

Trait Implementations§

source§

impl Debug for GrammarAST

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.