public class GllParser extends java.lang.Object implements GearleyParser
The GLL parser compares an input sequence against a grammar and determines if the input is a sentence in the grammar.
This is an attempt to implement the work described in Derivation representation using binary subtree sets by Elizabeth Scott, Adrian Johnstone, and L. Thomas van Binsbergen. It returns the SPPF style forest derived from the binary subtrees. (There's some aspect of the description of how to extract trees directly from the BSR that I cannot grok.)
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
gllexecution |
ParserGrammar |
grammar |
static java.lang.String |
logcategory |
Constructor and Description |
---|
GllParser(ParserGrammar grammar,
ParserOptions options) |
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()
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()
The parser type.
|
NonterminalSymbol |
getSeed()
The seed used by this parser.
|
Token[] |
getTokens() |
boolean |
hasMoreInput()
Returns true of the parse ended without consuming all input.
|
GllResult |
parse(java.util.Iterator<Token> input)
Parse a sequence of tokens provided by an iterator.
|
GllResult |
parse(java.lang.String input)
Parse a string.
|
GllResult |
parse(Token[] input)
Parse an array of tokens.
|
boolean |
succeeded() |
public static final java.lang.String logcategory
public static final java.lang.String gllexecution
public final ParserGrammar grammar
public GllParser(ParserGrammar grammar, ParserOptions options)
public GllResult parse(Token[] input)
GearleyParser
Note that the GLL parser only parses character tokens.
parse
in interface GearleyParser
input
- The array of tokens.public GllResult parse(java.util.Iterator<Token> input)
GearleyParser
Note that the GLL parser only parses character tokens.
parse
in interface GearleyParser
input
- The token iterator.public GllResult parse(java.lang.String input)
GearleyParser
parse
in interface GearleyParser
input
- The input string.public boolean succeeded()
public Token[] getTokens()
public ParserType getParserType()
GearleyParser
getParserType
in interface GearleyParser
public ParserGrammar getGrammar()
GearleyParser
getGrammar
in interface GearleyParser
public NonterminalSymbol getSeed()
GearleyParser
getSeed
in interface GearleyParser
public boolean hasMoreInput()
GearleyParser
hasMoreInput
in interface GearleyParser
public int getOffset()
GearleyParser
getOffset
in interface GearleyParser
public int getLineNumber()
GearleyParser
getLineNumber
in interface GearleyParser
public int getColumnNumber()
GearleyParser
getColumnNumber
in interface GearleyParser