public class EarleyParser extends java.lang.Object implements GearleyParser
The Earley parser compares an input sequence against a grammar and determines if the input is a sentence in the grammar.
This is a fairly literal implementation of the parser in ยง5 of SPPF-Style Parsing From Earley Recognisers.
| Modifier and Type | Field and Description | 
|---|---|
| static java.lang.String | logcategory | 
| Modifier and Type | Method and Description | 
|---|---|
| int | getColumnNumber()Returns the column number of the last character on the last line read by the parser. | 
| ParserGrammar | getGrammar()Get the grammar used by this parser. | 
| int | getLineNumber()Returns the line number of the last line read by the parser. | 
| int | getOffset()Returns the last offset read by the parser. | 
| ParserType | getParserType()Return the parser type. | 
| NonterminalSymbol | getSeed()Get the  NonterminalSymbolseed value used by this parser. | 
| boolean | hasMoreInput()Is there more input? | 
| EarleyResult | parse(java.util.Iterator<Token> input)Parse a sequence of tokens against the grammar. | 
| EarleyResult | parse(java.lang.String input)Parse an input string against the grammar. | 
| EarleyResult | parse(Token[] input)Parse an array of tokens against the grammar. | 
public static final java.lang.String logcategory
public ParserType getParserType()
getParserType in interface GearleyParserParserType.Earleypublic ParserGrammar getGrammar()
getGrammar in interface GearleyParserpublic NonterminalSymbol getSeed()
NonterminalSymbol seed value used by this parser.getSeed in interface GearleyParserpublic EarleyResult parse(java.lang.String input)
This is a shortcut for parsing a sequence of characters.
parse in interface GearleyParserinput - the input stringpublic EarleyResult parse(Token[] input)
You must not change the input array.
parse in interface GearleyParserinput - the input arraypublic EarleyResult parse(java.util.Iterator<Token> input)
parse in interface GearleyParserinput - the input sequencepublic boolean hasMoreInput()
If the parse succeeded, the answer will always be false. But a failed parse can fail because it was unable to process a token or because it ran out of tokens. This method checks if there was any more input after the parse completed.
hasMoreInput in interface GearleyParserpublic int getLineNumber()
GearleyParsergetLineNumber in interface GearleyParserpublic int getColumnNumber()
GearleyParsergetColumnNumber in interface GearleyParserpublic int getOffset()
GearleyParsergetOffset in interface GearleyParser