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}:
preeffects go on the first item (entry)posteffects go on the last item (exit)
For tagged alternations [A: body]:
precontainsEnum(variant)for branch entrypostcontainsEndEnumfor 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
impl CaptureEffects
Sourcepub fn new(pre: Vec<EffectIR>, post: Vec<EffectIR>) -> Self
pub fn new(pre: Vec<EffectIR>, post: Vec<EffectIR>) -> Self
Create with explicit pre and post effects.
Sourcepub fn nest_scope(self, open: EffectIR, close: EffectIR) -> Self
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
Sourcepub fn with_pre_values(self, effects: Vec<EffectIR>) -> Self
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]
Sourcepub fn with_post_values(self, effects: Vec<EffectIR>) -> Self
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
impl Clone for CaptureEffects
Source§fn clone(&self) -> CaptureEffects
fn clone(&self) -> CaptureEffects
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more