Class Nonterminal
Represents a nonterminal symbol in a grammar to be built that does not produce a value, and allows setting its productions after its creation.
public sealed class Nonterminal : IGrammarSymbol, IGrammarBuilder
- Inheritance
-
Nonterminal
- Implements
- Extension Methods
Remarks
In Farkle, builder objects are usually immutable. This exception exists to support defining recursive nonterminals.
Properties
Name
The symbol's name.
public string Name { get; }
Property Value
Remarks
This value is used only for diagnostic and documentation purposes and does not affect the grammar's behavior when parsing. A grammar may contain multiple symbols with the same name.
Methods
SetProductions(params ProductionBuilder[])
Sets the productions of this nonterminal.
public void SetProductions(params ProductionBuilder[] productions)
Parameters
productions
ProductionBuilder[]An array with the productions to set. The productions are represented as ProductionBuilder objects that have not been
Extend
ed orFinish
ed.
Remarks
This function and its overloads must be called exactly once, and before the nonterminal is used in building a grammar.
Exceptions
- ArgumentException
productions
is empty.- InvalidOperationException
The productions have already been successfully set.
SetProductions(params ImmutableArray<ProductionBuilder>)
Sets the productions of this nonterminal.
public void SetProductions(params ImmutableArray<ProductionBuilder> productions)
Parameters
productions
ImmutableArray<ProductionBuilder>The productions to set. The productions are represented as ProductionBuilder objects that have not been
Extend
ed orFinish
ed.
Remarks
This function and its overloads must be called exactly once, and before the nonterminal is used in building a grammar.
Exceptions
- ArgumentException
productions
is empty.- InvalidOperationException
The productions have already been successfully set.