public abstract class Grammar
extends java.lang.Object
This is an abstract class with two implementations: SourceGrammar
and ParserGrammar
.
The source grammar can be updated, the parser grammar is immutable.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
logcategory |
Constructor and Description |
---|
Grammar() |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.String> |
getMetadataProperies()
Gets the metadata properties.
|
java.lang.String |
getMetadataProperty(java.lang.String name)
Gets a metadata property.
|
java.util.List<Rule> |
getRules()
Get the rules currently defined in this grammar.
|
java.util.Map<NonterminalSymbol,java.util.List<Rule>> |
getRulesBySymbol()
Get the rules currently defined in this grammar organized by symbol.
|
java.util.List<Rule> |
getRulesForSymbol(NonterminalSymbol symbol)
Get the rules currently defined in this grammar for a particular symbol.
|
java.util.Set<NonterminalSymbol> |
getSymbols()
Get the currently defined nonterminals in the grammar.
|
abstract boolean |
isNullable(Symbol symbol)
Is the symbol nullable?
|
public static final java.lang.String logcategory
public java.util.List<Rule> getRules()
For a ParserGrammar
, this is the final set.
public java.util.Set<NonterminalSymbol> getSymbols()
For a ParserGrammar
, this is the final set.
public java.util.Map<NonterminalSymbol,java.util.List<Rule>> getRulesBySymbol()
For a ParserGrammar
, this is the final set.
public java.util.List<Rule> getRulesForSymbol(NonterminalSymbol symbol)
For a ParserGrammar
, this is the final set.
symbol
- The symbol.public java.lang.String getMetadataProperty(java.lang.String name)
Metadata properties exist solely for annotations by an application.
name
- the name of the propertyjava.lang.NullPointerException
- if the name is nullpublic java.util.Map<java.lang.String,java.lang.String> getMetadataProperies()
Metadata properties exist solely for annotations by an application.
public abstract boolean isNullable(Symbol symbol)
A TerminalSymbol
is never nullable.
For a ParserGrammar
, the answer is definitive. For an SourceGrammar
,
a symbol that isn't currently nullable could become nullable by the addition of more rules.
symbol
- The symbol.