Skip to main content

BuiltGraph

Struct BuiltGraph 

Source
pub struct BuiltGraph {
    pub insns: Vec<Insn>,
    pub rule_entry: Vec<InsnId>,
    pub literal_data: Vec<u8>,
    pub literal_offsets: Vec<u32>,
    pub jump_tables: Vec<[u32; 256]>,
    pub flag_mask_data: Vec<FlagMaskWord>,
    pub flag_mask_offsets: Vec<u32>,
    pub rule_names: Vec<&'static str>,
    pub tag_names: Vec<&'static str>,
    pub class_labels: Vec<&'static str>,
    pub expected_labels: Vec<&'static str>,
    pub field_names: Vec<&'static str>,
}
Expand description

The fully-built grammar tables, ready to be handed to the parse engine.

Call as_graph to obtain a ParseGraph that borrows from this value. Keep BuiltGraph alive for as long as the ParseGraph (or any derived references) are in use.

Fields§

§insns: Vec<Insn>§rule_entry: Vec<InsnId>§literal_data: Vec<u8>§literal_offsets: Vec<u32>§jump_tables: Vec<[u32; 256]>§flag_mask_data: Vec<FlagMaskWord>§flag_mask_offsets: Vec<u32>§rule_names: Vec<&'static str>§tag_names: Vec<&'static str>§class_labels: Vec<&'static str>

Labels for Insn::Class diagnostics; index 0 is the default “character class”.

§expected_labels: Vec<&'static str>

Labels for expect_label.

§field_names: Vec<&'static str>

Names for named child fields (indexed by FieldId); used by field_by_id / name resolution.

Implementations§

Source§

impl BuiltGraph

Source

pub fn as_graph(&self) -> ParseGraph

Return a ParseGraph that borrows all tables from this BuiltGraph.

§Safety and lifetime

ParseGraph uses &'static [T] slices so it can be Copy and embedded in static grammars. Here those references are produced by casting the backing Vec pointers. You must ensure:

  • The BuiltGraph is not mutated after as_graph is called, and
  • The BuiltGraph outlives every use of the returned ParseGraph (do not drop or move the BuiltGraph while the graph is in use).

Violating these conditions is undefined behavior. In typical usage the BuiltGraph is stored in a variable that outlives the parse call (e.g. let built = g.finish()?; let graph = built.as_graph();).

Source

pub fn field_id(&self, name: &str) -> Option<FieldId>

Resolve a field name to its FieldId. Returns the index of the first matching name in field_names, or None if not found.

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.