Class ParserDefinition
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:
- LexerEngine — to tokenize an input stream,
- ParserEngine — to build a parse tree.
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
NamestringTypeGrammarTypeOptionsGrammarOptionsActionsIReadOnlyList<GrammarAction>ImportsIReadOnlyList<GrammarImport>ModesIReadOnlyList<LexerMode>ParserRulesIReadOnlyList<Rule>RootRuleRule
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:
- LexerEngine — to tokenize an input stream,
- ParserEngine — to build a parse tree.
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
NamestringTypeGrammarTypeOptionsGrammarOptionsActionsIReadOnlyList<GrammarAction>ImportsIReadOnlyList<GrammarImport>ModesIReadOnlyList<LexerMode>DeclaredTokensIReadOnlySet<string>DeclaredChannelsIReadOnlySet<string>ExtensionBindingsIReadOnlyList<GrammarExtensionBinding>ParserRulesIReadOnlyList<Rule>RootRuleRule
Properties
Actions
Gets the immutable snapshot of top-level action blocks.
public IReadOnlyList<GrammarAction> Actions { get; init; }
Property Value
AllRules
Gets the immutable ordinal lookup of all rules.
public IReadOnlyDictionary<string, Rule> AllRules { get; init; }
Property Value
AllowExternalLexerRules
Allows parser grammars to include external lexer rules provided by project-level compilation.
public bool AllowExternalLexerRules { get; init; }
Property Value
DeclaredChannels
Gets the immutable ordinal set of declared channels.
public IReadOnlySet<string> DeclaredChannels { get; init; }
Property Value
DeclaredTokens
Gets the immutable ordinal set of declared tokens.
public IReadOnlySet<string> DeclaredTokens { get; init; }
Property Value
EffectiveOptions
public EffectiveGrammarOptions EffectiveOptions { get; init; }
Property Value
ExtensionBindings
Gets the immutable snapshot of extension bindings.
public IReadOnlyList<GrammarExtensionBinding> ExtensionBindings { get; init; }
Property Value
Imports
Gets the immutable snapshot of grammar imports.
public IReadOnlyList<GrammarImport> Imports { get; init; }
Property Value
LeftRecursiveRules
Gets the immutable ordinal lookup of left-recursive rules.
public IReadOnlyDictionary<string, LeftRecursiveRuleInfo> LeftRecursiveRules { get; init; }
Property Value
Modes
Gets the immutable snapshot of lexer modes.
public IReadOnlyList<LexerMode> Modes { get; init; }
Property Value
Name
public string Name { get; init; }
Property Value
Options
public GrammarOptions? Options { get; init; }
Property Value
ParserRules
Gets the immutable snapshot of parser rules.
public IReadOnlyList<Rule> ParserRules { get; init; }
Property Value
RootRule
public Rule? RootRule { get; init; }
Property Value
Type
public GrammarType Type { get; init; }