Package org.nineml.coffeegrinder.parser
Class Grammar
java.lang.Object
org.nineml.coffeegrinder.parser.Grammar
- Direct Known Subclasses:
ParserGrammar,SourceGrammar
The grammar representation.
This is an abstract class with two implementations: SourceGrammar and ParserGrammar.
The source grammar can be updated, the parser grammar is immutable.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the metadata properties.getMetadataProperty(String name) Gets a metadata property.getRules()Get the rules currently defined in this grammar.Get the rules currently defined in this grammar organized by symbol.getRulesForSymbol(NonterminalSymbol symbol) Get the rules currently defined in this grammar for a particular symbol.Get the currently defined nonterminals in the grammar.abstract booleanisNullable(Symbol symbol) Is the symbol nullable?
-
Field Details
-
logcategory
- See Also:
-
-
Constructor Details
-
Grammar
public Grammar()
-
-
Method Details
-
getRules
Get the rules currently defined in this grammar.For a
ParserGrammar, this is the final set.- Returns:
- Returns the rules that define the grammar.
-
getSymbols
Get the currently defined nonterminals in the grammar.For a
ParserGrammar, this is the final set.- Returns:
- the set of nonterminals.
-
getRulesBySymbol
Get the rules currently defined in this grammar organized by symbol.For a
ParserGrammar, this is the final set.- Returns:
- Returns the rules that define the grammar.
-
getRulesForSymbol
Get the rules currently defined in this grammar for a particular symbol.For a
ParserGrammar, this is the final set.- Parameters:
symbol- The symbol.- Returns:
- Returns the rules that define the grammar.
-
getMetadataProperty
Gets a metadata property.Metadata properties exist solely for annotations by an application.
- Parameters:
name- the name of the property- Returns:
- the value of the property, or null if no such property exists
- Throws:
NullPointerException- if the name is null
-
getMetadataProperies
Gets the metadata properties.Metadata properties exist solely for annotations by an application.
- Returns:
- the metadata properties
-
isNullable
Is the symbol nullable?A
TerminalSymbolis never nullable.For a
ParserGrammar, the answer is definitive. For anSourceGrammar, a symbol that isn't currently nullable could become nullable by the addition of more rules.- Parameters:
symbol- The symbol.- Returns:
- true if the symbol is nullable
-