CaptureEffects

Struct CaptureEffects 

Source
pub struct CaptureEffects {
    pub pre: Vec<EffectIR>,
    pub post: Vec<EffectIR>,
}
Expand description

Capture effects to attach to match instructions.

Instead of emitting separate epsilon transitions for wrapper effects, these effects are propagated through the compilation chain and attached directly to match instructions.

For sequences {a b c}:

  • pre effects go on the first item (entry)
  • post effects go on the last item (exit)

For tagged alternations [A: body]:

  • pre contains Enum(variant) for branch entry
  • post contains EndEnum for branch exit

Fields§

§pre: Vec<EffectIR>

Effects to place as pre_effects on the entry instruction. Used for: Enum(variant) in tagged alternations.

§post: Vec<EffectIR>

Effects to place as post_effects on the exit instruction. Typically: [Node/Text, Set(member)], [Push], or [EndEnum].

Implementations§

Source§

impl CaptureEffects

Source

pub fn new(pre: Vec<EffectIR>, post: Vec<EffectIR>) -> Self

Create with explicit pre and post effects.

Source

pub fn new_pre(pre: Vec<EffectIR>) -> Self

Create with only pre effects.

Source

pub fn new_post(post: Vec<EffectIR>) -> Self

Create with only post effects.

Source

pub fn nest_scope(self, open: EffectIR, close: EffectIR) -> Self

Add an inner scope (opens after existing scopes, closes before them).

Use for: Obj/EndObj, Enum/EndEnum, Arr/EndArr, SuppressBegin/SuppressEnd

Given existing pre=[A_Open], post=[A_Close], adding inner scope B:

  • Result: pre=[A_Open, B_Open], post=[B_Close, A_Close]
  • Execution: A opens -> B opens -> match -> B closes -> A closes
Source

pub fn with_pre_values(self, effects: Vec<EffectIR>) -> Self

Add pre-match value effects (run after all scopes open).

Use for: Null+Set injection in untagged alternations

Given pre=[Scope_Open], adding value effects:

  • Result: pre=[Scope_Open, Value1, Value2]
Source

pub fn with_post_values(self, effects: Vec<EffectIR>) -> Self

Add post-match value effects (run before any scope closes).

Use for: Node/Text+Set capture effects, Push for arrays

Given post=[Scope_Close], adding value effects:

  • Result: post=[Value1, Value2, Scope_Close]

Trait Implementations§

Source§

impl Clone for CaptureEffects

Source§

fn clone(&self) -> CaptureEffects

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for CaptureEffects

Source§

fn default() -> CaptureEffects

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 = 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.