Skip to main content

CompiledTable

Struct CompiledTable 

Source
pub struct CompiledTable { /* private fields */ }
Expand description

Owned parse table data produced by CompiledTable::build.

This holds the compressed table arrays, grammar, and conflict info. Use CompiledTable::table to get a lightweight [ParseTable] for parsing.

Implementations§

Source§

impl CompiledTable

Source

pub fn build(grammar: &Grammar) -> Result<Self, String>

Build parse tables from a grammar.

Returns an error if grammar conversion fails (for example, unknown symbols).

Source

pub fn table(&self) -> ParseTable<'_>

Get a lightweight [ParseTable] borrowing from this compiled table.

Source

pub fn has_conflicts(&self) -> bool

Returns true if the table has conflicts.

Source

pub fn format_conflicts(&self) -> Vec<String>

Format conflicts as human-readable error messages (one string per conflict).

Source

pub fn symbol_id(&self, name: &str) -> Option<SymbolId>

Lookup symbol ID by name.

Source

pub fn symbol_name(&self, id: SymbolId) -> &str

Get the name of a symbol by ID.

Source

pub fn num_symbols(&self) -> u32

Get the total number of symbols.

Source

pub fn num_terminals(&self) -> u32

Get the number of terminal symbols.

Source

pub fn num_states(&self) -> usize

Get the number of parser states.

Source

pub fn conflicts(&self) -> &[Conflict]

Get the conflicts detected during table construction, paired with examples.

Trait Implementations§

Source§

impl Debug for CompiledTable

Source§

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

Formats the value using the given formatter. Read more
Source§

impl ErrorContext for CompiledTable

Source§

fn symbol_name(&self, id: SymbolId) -> &str

Get the name for a symbol ID.
Source§

fn state_symbol(&self, state: usize) -> SymbolId

Get the accessing symbol for a state (the symbol shifted/reduced to enter it).
Source§

fn state_items(&self, state: usize) -> &[(u16, u8)]

Get active LR items for a state. Each pair is (rule_index, dot_position): the dot position is how far into the rule’s RHS the parser has progressed.
Source§

fn rule_rhs(&self, rule: usize) -> &[u32]

Get the RHS symbol IDs for a rule (each ID indexes into symbol_name).

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.