Package org.nineml.coffeegrinder.parser
Class ParserGrammar
- java.lang.Object
-
- org.nineml.coffeegrinder.parser.Grammar
-
- org.nineml.coffeegrinder.parser.ParserGrammar
-
public class ParserGrammar extends Grammar
A grammar for the parser.A grammar is a list of rules. Each rule defines a non-terminal symbol as a sequence of zero or more symbols (terminal or nonterminal).
A grammar can be used to create a parser for that grammar. The ParserGrammar is derived from a
SourceGrammar. The ParserGrammar is immutable.
-
-
Field Summary
Fields Modifier and Type Field Description booleanusesRegex-
Fields inherited from class org.nineml.coffeegrinder.parser.Grammar
logcategory
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<Symbol>getFirst(Symbol symbol)Return the set of "first" symbols for the specified symboljava.util.Set<Symbol>getFollow(Symbol symbol)HygieneReportgetHygieneReport()Get a hygiene report for this compiled grammar.GearleyParsergetParser()Get a parser for this grammar.ParserOptionsgetParserOptions()NonterminalSymbolgetSeed()booleanisNullable(Symbol symbol)Is a symbol nullable?-
Methods inherited from class org.nineml.coffeegrinder.parser.Grammar
getMetadataProperies, getMetadataProperty, getRules, getRulesBySymbol, getRulesForSymbol, getSymbols
-
-
-
-
Method Detail
-
getSeed
public NonterminalSymbol getSeed()
-
getParserOptions
public ParserOptions getParserOptions()
-
getParser
public GearleyParser getParser()
Get a parser for this grammar.Returns a parser that will parse an input against the rules that define this grammar.
- Returns:
- the parser
-
isNullable
public boolean isNullable(Symbol symbol)
Is a symbol nullable?- Specified by:
isNullablein classGrammar- Parameters:
symbol- the symbol- Returns:
- true if the symbol is nullable
- Throws:
java.lang.UnsupportedOperationException- if the grammar is open
-
getHygieneReport
public HygieneReport getHygieneReport()
Get a hygiene report for this compiled grammar.- Returns:
- the report.
-
getFirst
public java.util.Set<Symbol> getFirst(Symbol symbol)
Return the set of "first" symbols for the specified symbolThe first symbols of a nonterminal are all those symbols that can appear "first" in a matching parse for that nonterminal. The first set of a terminal symbol is just the symbol itself.
- Parameters:
symbol- the symbol of interest- Returns:
- the first set for the symbol
-
-