Table of Contents

Class ParserDefinition

Namespace
Utils.Parser.Model
Assembly
Utils.Parser.dll

Complete, immutable description of a grammar produced either by loading a .g4 file through Antlr4GrammarConverter or by constructing the meta-grammar programmatically (as done in Antlr4Grammar.Build()).

A ParserDefinition is consumed by:

After construction, call RuleResolver.Resolve(definition) to populate AllRules and validate rule references.

public record ParserDefinition : IEquatable<ParserDefinition>
Inheritance
ParserDefinition
Implements
Inherited Members
Extension Methods

Constructors

ParserDefinition(string, GrammarType, GrammarOptions?, IReadOnlyList<GrammarAction>, IReadOnlyList<GrammarImport>, IReadOnlyList<LexerMode>, IReadOnlyList<Rule>, Rule?)

Backward-compatible constructor used by generated code that does not provide extension metadata.

public ParserDefinition(string Name, GrammarType Type, GrammarOptions? Options, IReadOnlyList<GrammarAction> Actions, IReadOnlyList<GrammarImport> Imports, IReadOnlyList<LexerMode> Modes, IReadOnlyList<Rule> ParserRules, Rule? RootRule)

Parameters

Name string
Type GrammarType
Options GrammarOptions
Actions IReadOnlyList<GrammarAction>
Imports IReadOnlyList<GrammarImport>
Modes IReadOnlyList<LexerMode>
ParserRules IReadOnlyList<Rule>
RootRule Rule

ParserDefinition(string, GrammarType, GrammarOptions?, IReadOnlyList<GrammarAction>, IReadOnlyList<GrammarImport>, IReadOnlyList<LexerMode>, IReadOnlySet<string>?, IReadOnlySet<string>?, IReadOnlyList<GrammarExtensionBinding>?, IReadOnlyList<Rule>, Rule?)

Complete, immutable description of a grammar produced either by loading a .g4 file through Antlr4GrammarConverter or by constructing the meta-grammar programmatically (as done in Antlr4Grammar.Build()).

A ParserDefinition is consumed by:

After construction, call RuleResolver.Resolve(definition) to populate AllRules and validate rule references.

public ParserDefinition(string Name, GrammarType Type, GrammarOptions? Options, IReadOnlyList<GrammarAction> Actions, IReadOnlyList<GrammarImport> Imports, IReadOnlyList<LexerMode> Modes, IReadOnlySet<string>? DeclaredTokens, IReadOnlySet<string>? DeclaredChannels, IReadOnlyList<GrammarExtensionBinding>? ExtensionBindings, IReadOnlyList<Rule> ParserRules, Rule? RootRule)

Parameters

Name string
Type GrammarType
Options GrammarOptions
Actions IReadOnlyList<GrammarAction>
Imports IReadOnlyList<GrammarImport>
Modes IReadOnlyList<LexerMode>
DeclaredTokens IReadOnlySet<string>
DeclaredChannels IReadOnlySet<string>
ExtensionBindings IReadOnlyList<GrammarExtensionBinding>
ParserRules IReadOnlyList<Rule>
RootRule Rule

Properties

Actions

Gets the immutable snapshot of top-level action blocks.

public IReadOnlyList<GrammarAction> Actions { get; init; }

Property Value

IReadOnlyList<GrammarAction>

AllRules

Gets the immutable ordinal lookup of all rules.

public IReadOnlyDictionary<string, Rule> AllRules { get; init; }

Property Value

IReadOnlyDictionary<string, Rule>

AllowExternalLexerRules

Allows parser grammars to include external lexer rules provided by project-level compilation.

public bool AllowExternalLexerRules { get; init; }

Property Value

bool

DeclaredChannels

Gets the immutable ordinal set of declared channels.

public IReadOnlySet<string> DeclaredChannels { get; init; }

Property Value

IReadOnlySet<string>

DeclaredTokens

Gets the immutable ordinal set of declared tokens.

public IReadOnlySet<string> DeclaredTokens { get; init; }

Property Value

IReadOnlySet<string>

EffectiveOptions

Normalized effective options derived from Options and Type. Populated by RuleResolver.Resolve.

public EffectiveGrammarOptions EffectiveOptions { get; init; }

Property Value

EffectiveGrammarOptions

ExtensionBindings

Gets the immutable snapshot of extension bindings.

public IReadOnlyList<GrammarExtensionBinding> ExtensionBindings { get; init; }

Property Value

IReadOnlyList<GrammarExtensionBinding>

Imports

Gets the immutable snapshot of grammar imports.

public IReadOnlyList<GrammarImport> Imports { get; init; }

Property Value

IReadOnlyList<GrammarImport>

LeftRecursiveRules

Gets the immutable ordinal lookup of left-recursive rules.

public IReadOnlyDictionary<string, LeftRecursiveRuleInfo> LeftRecursiveRules { get; init; }

Property Value

IReadOnlyDictionary<string, LeftRecursiveRuleInfo>

Modes

Gets the immutable snapshot of lexer modes.

public IReadOnlyList<LexerMode> Modes { get; init; }

Property Value

IReadOnlyList<LexerMode>

Name

public string Name { get; init; }

Property Value

string

Options

public GrammarOptions? Options { get; init; }

Property Value

GrammarOptions

ParserRules

Gets the immutable snapshot of parser rules.

public IReadOnlyList<Rule> ParserRules { get; init; }

Property Value

IReadOnlyList<Rule>

RootRule

public Rule? RootRule { get; init; }

Property Value

Rule

Type

public GrammarType Type { get; init; }

Property Value

GrammarType