Skip to main content

AltSpec

Struct AltSpec 

Source
pub struct AltSpec {
Show 31 fields pub s: Vec<Vec<Tin>>, pub s_names: Vec<Vec<String>>, pub s_bound: Vec<Vec<Tin>>, pub p: Option<String>, pub p_fn: Option<AltNext>, pub p_match: Option<AltNextWithMatch>, pub r: Option<String>, pub r_fn: Option<AltNext>, pub r_match: Option<AltNextWithMatch>, pub b: usize, pub b_fn: Option<AltBack>, pub b_match: Option<AltBackWithMatch>, pub a: Vec<String>, pub action_fns: Vec<ContextAction>, pub action_order: Vec<AltActionBinding>, pub matched_action_fns: Vec<AltAction>, pub action_configs: HashMap<String, Value>, pub c: Vec<Condition>, pub c_ref: Option<String>, pub c_fn: Option<AltCondition>, pub c_match: Option<AltConditionWithMatch>, pub c_lex: Option<AltConditionWithLexer>, pub c_lex_match: Option<AltConditionWithLexerAndMatch>, pub n: HashMap<String, i32>, pub u: HashMap<String, Value>, pub k: HashMap<String, Value>, pub g: String, pub h: Option<AltModifier>, pub h_match: Option<AltModifierWithMatch>, pub e: Option<AltError>, pub e_match: Option<AltErrorWithMatch>,
}

Fields§

§s: Vec<Vec<Tin>>§s_names: Vec<Vec<String>>

The token names each s slot was declared with, when the alternate came from a serialized grammar; empty for an alternate built from tins directly. A slot naming a token set (#KEY, #VAL, a custom set) is resolved again against the instance’s options whenever the parser is rebuilt, so a set overridden after the alternate was installed still reaches it, as in TypeScript and Go (tabnas/parser#217).

§s_bound: Vec<Vec<Tin>>

What s_names last resolved to, slot by slot. A slot whose s no longer equals this was set by hand after the alternate was installed, and that edit wins: the names are not applied over it.

§p: Option<String>§p_fn: Option<AltNext>§p_match: Option<AltNextWithMatch>§r: Option<String>§r_fn: Option<AltNext>§r_match: Option<AltNextWithMatch>§b: usize§b_fn: Option<AltBack>§b_match: Option<AltBackWithMatch>§a: Vec<String>§action_fns: Vec<ContextAction>

Imperative actions installed directly by a native Rust plugin. Named actions in a remain the serialized grammar representation; action_order retains their exact interleaving with direct callbacks.

§action_order: Vec<AltActionBinding>§matched_action_fns: Vec<AltAction>§action_configs: HashMap<String, Value>§c: Vec<Condition>§c_ref: Option<String>§c_fn: Option<AltCondition>§c_match: Option<AltConditionWithMatch>§c_lex: Option<AltConditionWithLexer>§c_lex_match: Option<AltConditionWithLexerAndMatch>§n: HashMap<String, i32>§u: HashMap<String, Value>§k: HashMap<String, Value>§g: String§h: Option<AltModifier>§h_match: Option<AltModifierWithMatch>§e: Option<AltError>§e_match: Option<AltErrorWithMatch>

Implementations§

Source§

impl AltSpec

Source

pub fn new() -> Self

Source§

impl AltSpec

Source

pub fn add_action( &mut self, action: impl Fn(&mut Rule, &mut Context) + Send + Sync + 'static, ) -> &mut Self

Append an imperative Rust action to this alternate.

Source

pub fn prepend_action( &mut self, action: impl Fn(&mut Rule, &mut Context) + Send + Sync + 'static, ) -> &mut Self

Prepend an imperative Rust action ahead of existing named or direct actions.

Source

pub fn add_action_result(&mut self, action: ContextAction) -> &mut Self

Append a fallible imperative Rust action to this alternate.

Source

pub fn prepend_action_result(&mut self, action: ContextAction) -> &mut Self

Source

pub fn add_action_with_match( &mut self, action: impl Fn(&mut Rule, &mut Context, &AltMatch) -> Option<Token> + Send + Sync + 'static, ) -> &mut Self

Append an action with the complete matched-alternate argument.

Source

pub fn prepend_action_with_match( &mut self, action: impl Fn(&mut Rule, &mut Context, &AltMatch) -> Option<Token> + Send + Sync + 'static, ) -> &mut Self

Source

pub fn add_action_with_match_result(&mut self, action: AltAction) -> &mut Self

Source

pub fn prepend_action_with_match_result( &mut self, action: AltAction, ) -> &mut Self

Source

pub fn add_action_ref(&mut self, action: impl Into<String>) -> &mut Self

Source

pub fn prepend_action_ref(&mut self, action: impl Into<String>) -> &mut Self

Trait Implementations§

Source§

impl Clone for AltSpec

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for AltSpec

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.