Class GrammarExtensions
Provides extension methods on Grammar and IGrammarProvider.
public static class GrammarExtensions
- Inheritance
-
GrammarExtensions
Methods
GetNonterminalFromSpecialName(IGrammarProvider, string, bool)
Looks up a nonterminal with the specified special name.
public static NonterminalHandle GetNonterminalFromSpecialName(this IGrammarProvider grammarProvider, string specialName, bool throwIfNotFound = true)
Parameters
grammarProvider
IGrammarProviderThe grammar provider.
specialName
stringThe symbol's special name.
throwIfNotFound
boolWhether to throw an exception if the symbol was not found. Defaults to
.
Returns
- NonterminalHandle
A TokenSymbolHandle pointing to the nonterminal with the specified special name, or pointing to nothing if the symbol was not found and
throwIfNotFound
has a value of false.
Remarks
Special names are intended to be used on nonterminals that will be emitted by custom tokenizers. Because symbol names are not guaranteed to be unique, a special name provides a guaranteed way to retrieve the handle for a specific symbol.
Exceptions
- KeyNotFoundException
The symbol was not found or is not a nonterminal, and
throwIfNotFound
had a value of true.
GetTokenSymbolFromSpecialName(IGrammarProvider, string, bool)
Looks up a token symbol with the specified special name.
public static TokenSymbolHandle GetTokenSymbolFromSpecialName(this IGrammarProvider grammarProvider, string specialName, bool throwIfNotFound = true)
Parameters
grammarProvider
IGrammarProviderThe grammar provider.
specialName
stringThe symbol's special name.
throwIfNotFound
boolWhether to throw an exception if the symbol was not found. Defaults to
.
Returns
- TokenSymbolHandle
A TokenSymbolHandle pointing to the token symbol with the specified special name, or pointing to nothing if the symbol was not found and
throwIfNotFound
has a value of false.
Remarks
Special names are intended to be used on token symbols that will be emitted by custom tokenizers. Because symbol names are not guaranteed to be unique, a special name provides a guaranteed way to retrieve the handle for a specific symbol.
Exceptions
- KeyNotFoundException
The symbol was not found or is not a token symbol, and
throwIfNotFound
had a value of true.