pub struct FixedSymTable { /* private fields */ }Expand description
Stores the names of the terminal and nonterminal symbols used by a parser.
Terminals are defined in the lexicon. They have two parts to their name:
- the identifier in the lexicon
- the source string they represent (optional)
For example:
Plus : '+';
...
ID : [a-zA-Z][a-zA-Z_0-9]*;If Arrow’s token ID is 0 and ID’s is 24,
ⓘ
t[0] = ("Plus".to_string(), Some("+".to_string()));
t[24] = ("ID".to_string(), None);Nonterminals are defined in the grammar, and possibly completed by new ones when the rules are adapted to the target parser. For example, recursive rules are transformed for LL(1) parsers, which usually adds extra rules.
expr: expr Plus term | term;If expr is 0 and term is 1,
ⓘ
nt[0] = "expr".to_string();
nt[1] = "term".to_string();
nt[2] = "expr_1".to_string(); // generated when removing the left recursionImplementations§
Source§impl FixedSymTable
impl FixedSymTable
pub fn new(t: Vec<(String, Option<String>)>, nt: Vec<String>) -> FixedSymTable
pub fn get_terminals(&self) -> impl Iterator<Item = &(String, Option<String>)>
pub fn get_num_t(&self) -> usize
pub fn get_nonterminals(&self) -> impl Iterator<Item = &String>
pub fn get_num_nt(&self) -> usize
Trait Implementations§
Source§impl Clone for FixedSymTable
impl Clone for FixedSymTable
Source§fn clone(&self) -> FixedSymTable
fn clone(&self) -> FixedSymTable
Returns a duplicate 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 moreSource§impl Debug for FixedSymTable
impl Debug for FixedSymTable
Source§impl SymInfoTable for FixedSymTable
impl SymInfoTable for FixedSymTable
Source§fn is_token_data(&self, token: u16) -> bool
fn is_token_data(&self, token: u16) -> bool
Does
Symbol::T(token) hold lexer string data? Read moreSource§fn is_symbol_t_data(&self, symbol: &Symbol) -> bool
fn is_symbol_t_data(&self, symbol: &Symbol) -> bool
Is
symbol a terminal holding lexer string data? Read morefn is_symbol_t_fixed(&self, symbol: &Symbol) -> bool
fn get_t_str(&self, token: u16) -> String
fn get_t_name(&self, token: u16) -> String
fn get_nt_name(&self, var: u16) -> String
Source§fn get_name(&self, symbol: &Symbol) -> String
fn get_name(&self, symbol: &Symbol) -> String
Gets the symbol’s name: the nonterminal identifier, the terminal identifier,
or “ε”, “$”, …
Source§fn get_str(&self, symbol: &Symbol) -> String
fn get_str(&self, symbol: &Symbol) -> String
Gets the symbol’s representation string: the nonterminal identifier, the
terminal string value (if it exists), or “ε”, “$”, …
fn get_name_quote(&self, symbol: &Symbol) -> String
Auto Trait Implementations§
impl Freeze for FixedSymTable
impl RefUnwindSafe for FixedSymTable
impl Send for FixedSymTable
impl Sync for FixedSymTable
impl Unpin for FixedSymTable
impl UnwindSafe for FixedSymTable
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
Source§impl<S> BuildFrom<S> for S
impl<S> BuildFrom<S> for S
Source§fn build_from(source: S) -> S
fn build_from(source: S) -> S
Converts to this type from the input type.
Source§impl<S, T> BuildInto<T> for Swhere
T: BuildFrom<S>,
impl<S, T> BuildInto<T> for Swhere
T: BuildFrom<S>,
Source§fn build_into(self) -> T
fn build_into(self) -> T
Calls T::from(self) to convert a [S] into a [T].
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> TryBuildInto<T> for Swhere
T: TryBuildFrom<S>,
impl<S, T> TryBuildInto<T> for Swhere
T: TryBuildFrom<S>,
Source§type Error = <T as TryBuildFrom<S>>::Error
type Error = <T as TryBuildFrom<S>>::Error
The type returned in the event of a conversion error.
Source§fn try_build_into(self) -> Result<T, <T as TryBuildFrom<S>>::Error>
fn try_build_into(self) -> Result<T, <T as TryBuildFrom<S>>::Error>
Performs the conversion.