Table of Contents

Class ParserRuleInvocationFrame

Namespace
Utils.Parser.Runtime
Assembly
Utils.Parser.dll

Represents passive per-invocation parser rule metadata state. Parameters, locals, returns, and labeled completed child calls remain untyped managed metadata; the frame does not bind ANTLR type syntax or expose implicit grammar variables.

public sealed class ParserRuleInvocationFrame
Inheritance
ParserRuleInvocationFrame
Inherited Members
Extension Methods

Constructors

ParserRuleInvocationFrame(string, int)

Initializes an empty parser rule invocation frame.

public ParserRuleInvocationFrame(string ruleName, int inputPosition)

Parameters

ruleName string

Name of the parser rule being invoked.

inputPosition int

Token-stream position at the time of rule entry.

ParserRuleInvocationFrame(string, int, IReadOnlyDictionary<string, object?>)

Initializes a parser rule invocation frame with passive parameter values.

public ParserRuleInvocationFrame(string ruleName, int inputPosition, IReadOnlyDictionary<string, object?> parameters)

Parameters

ruleName string

Name of the parser rule being invoked.

inputPosition int

Token-stream position at the time of rule entry.

parameters IReadOnlyDictionary<string, object>

Passive parameter values to expose through the frame.

ParserRuleInvocationFrame(string, int, IReadOnlyDictionary<string, object?>, ParserRuleInvocationDescriptor?)

Initializes a parser rule invocation frame with passive parameter values and rule metadata.

public ParserRuleInvocationFrame(string ruleName, int inputPosition, IReadOnlyDictionary<string, object?> parameters, ParserRuleInvocationDescriptor? descriptor)

Parameters

ruleName string

Name of the parser rule being invoked.

inputPosition int

Token-stream position at the time of rule entry.

parameters IReadOnlyDictionary<string, object>

Passive parameter values to expose through the frame.

descriptor ParserRuleInvocationDescriptor

Passive rule metadata descriptor to expose through the frame.

ParserRuleInvocationFrame(string, int, IReadOnlyDictionary<string, object?>, ParserRuleInvocationDescriptor?, ParserRuleInvocationFrame?)

Initializes a parser rule invocation frame with passive parameter values, rule metadata, and a parent frame.

public ParserRuleInvocationFrame(string ruleName, int inputPosition, IReadOnlyDictionary<string, object?> parameters, ParserRuleInvocationDescriptor? descriptor, ParserRuleInvocationFrame? parent)

Parameters

ruleName string

Name of the parser rule being invoked.

inputPosition int

Token-stream position at the time of rule entry.

parameters IReadOnlyDictionary<string, object>

Passive parameter values to expose through the frame.

descriptor ParserRuleInvocationDescriptor

Passive rule metadata descriptor to expose through the frame.

parent ParserRuleInvocationFrame

Parent invocation frame in the current call stack, or null for root-level rules.

Properties

Depth

Gets the zero-based call-stack depth of this invocation frame. Root-level rule frames have depth 0; each nested rule invocation increments the depth by 1.

public int Depth { get; }

Property Value

int

Descriptor

Gets passive rule-level metadata associated with this invocation frame, when supplied by the runtime.

public ParserRuleInvocationDescriptor? Descriptor { get; }

Property Value

ParserRuleInvocationDescriptor

InputPosition

Gets the token-stream position at the time of rule entry.

public int InputPosition { get; }

Property Value

int

LabeledCallResults

Gets the immutable assignment and list label results produced by successful direct child calls in this frame. Store replacement is synchronized with managed execution-state snapshots so failed parser attempts roll back changes.

public ParserLabeledRuleCallResultStore LabeledCallResults { get; }

Property Value

ParserLabeledRuleCallResultStore

LastCompletedChildCall

Gets the call result from the most recently completed successful direct child rule invocation, or null when no child rule has yet completed successfully in the current rule context. This value is set by the invocation-frame manager on successful child exit and is synchronized with the managed execution-state snapshot during parser backtracking restoration. It must not be stored in static or global fields; its rollback safety relies on the managed execution-state snapshot mechanism being active.

public ParserRuleCallResult? LastCompletedChildCall { get; }

Property Value

ParserRuleCallResult

Locals

Gets passive local values associated with this invocation frame.

public IReadOnlyDictionary<string, object?> Locals { get; }

Property Value

IReadOnlyDictionary<string, object>

Parameters

Gets passive parameter values associated with this invocation frame.

public IReadOnlyDictionary<string, object?> Parameters { get; }

Property Value

IReadOnlyDictionary<string, object>

Parent

Gets the parent invocation frame in the current parser rule call stack, or null when this is a root-level rule.

public ParserRuleInvocationFrame? Parent { get; }

Property Value

ParserRuleInvocationFrame

Returns

Gets passive return values associated with this invocation frame.

public IReadOnlyDictionary<string, object?> Returns { get; }

Property Value

IReadOnlyDictionary<string, object>

RuleName

Gets the name of the parser rule associated with this invocation frame.

public string RuleName { get; }

Property Value

string

Methods

ClearPendingChildParameters(string?)

Removes all pending child-parameter seeds for ruleName, or all seeds when ruleName is null.

public void ClearPendingChildParameters(string? ruleName = null)

Parameters

ruleName string

GetParameter(string)

Gets a parameter value by name.

public object? GetParameter(string name)

Parameters

name string

Parameter metadata name.

Returns

object

The parameter value associated with name.

Exceptions

KeyNotFoundException

Thrown when the parameter name is not present.

SetLocal(string, object?)

Sets a passive local value by metadata name.

public void SetLocal(string name, object? value)

Parameters

name string

Local metadata name.

value object

Local value to store.

SetPendingChildParameter(string, string, object?)

Seeds an untyped parameter value for the next invocation of ruleName as a direct child of this frame. Seeds are consumed and copied into the matching child frame when that rule is entered through the stack frame manager. Parameters are not auto-bound; rule call arguments are not evaluated.

public void SetPendingChildParameter(string ruleName, string parameterName, object? value)

Parameters

ruleName string

Name of the child rule that will receive the seed.

parameterName string

Parameter metadata name.

value object

Untyped parameter value to seed.

SetPendingChildParameters(string, IReadOnlyDictionary<string, object?>)

Atomically merges untyped parameter values for the next invocation of a named child rule.

public void SetPendingChildParameters(string ruleName, IReadOnlyDictionary<string, object?> values)

Parameters

ruleName string

Name of the child rule that will receive the seeds.

values IReadOnlyDictionary<string, object>

Parameter metadata names and untyped values to seed.

SetReturnValue(string, object?)

Sets a passive return value by metadata name.

public void SetReturnValue(string name, object? value)

Parameters

name string

Return metadata name.

value object

Return value to store.

TryConsumePendingChildParameters(string, out IReadOnlyDictionary<string, object?>)

Attempts to consume and remove the pending parameter seed for ruleName. On success, the seeds are removed from this frame and returned as a read-only snapshot.

public bool TryConsumePendingChildParameters(string ruleName, out IReadOnlyDictionary<string, object?> parameters)

Parameters

ruleName string

Name of the child rule whose seeds to consume.

parameters IReadOnlyDictionary<string, object>

Receives the pending parameter snapshot when present.

Returns

bool

true when seeds for ruleName were present; otherwise, false.

TryGetLocal(string, out object?)

Attempts to get a passive local value by metadata name.

public bool TryGetLocal(string name, out object? value)

Parameters

name string

Local metadata name.

value object

Receives the local value when present.

Returns

bool

true when the local name is present; otherwise, false.

TryGetParameter(string, out object?)

Attempts to get a parameter value by name.

public bool TryGetParameter(string name, out object? value)

Parameters

name string

Parameter metadata name.

value object

Receives the parameter value when present.

Returns

bool

true when the parameter name is present; otherwise, false.

TryGetReturnValue(string, out object?)

Attempts to get a passive return value by metadata name.

public bool TryGetReturnValue(string name, out object? value)

Parameters

name string

Return metadata name.

value object

Receives the return value when present.

Returns

bool

true when the return name is present; otherwise, false.