public class EarleyResult extends java.lang.Object implements GearleyResult
Modifier and Type | Method and Description |
---|---|
EarleyResult |
continueParsing()
Continue parsing from the last successfully matched prefix.
|
EarleyResult |
continueParsing(GearleyParser newParser)
Continue parsing from the last successfully matched prefix with a new parser.
|
Arborist |
getArborist()
Get an arborist to extract trees from the forest.
|
Arborist |
getArborist(Axe axe)
Get an arborist to extract trees from the forest.
|
EarleyChart |
getChart()
Get the Earley chart for the parse.
|
int |
getColumnNumber()
Returns the column number of the last character on the last line read by the parser.
|
ParseForest |
getForest()
Return the parse forest created by the parser.
|
Token |
getLastToken()
What was the last token parsed?
|
int |
getLineNumber()
Returns the line number of the last line read by the parser.
|
int |
getOffset()
Returns the last offset read by the parser.
|
EarleyParser |
getParser()
Get the parser for this result.
|
long |
getParseTime()
How long did the parse take?
|
java.util.Set<TerminalSymbol> |
getPredictedTerminals()
Returns the symbols predicted as possibly next in the case where a parse fails.
|
Token[] |
getSuffix() |
int |
getTokenCount()
How many tokens were parsed?
|
boolean |
isAmbiguous()
Returns true if the parse was ambiguous.
|
boolean |
isInfinitelyAmbiguous()
Returns true if the parse was infinitely ambiguous.
|
boolean |
prefixSucceeded()
Did the parse match the beginning of the input?
|
boolean |
succeeded()
Did the parse succeed?
|
public long getParseTime()
Returns the number of milliseconds required to parse the input. Returns -1 if the timing is unavailable.
getParseTime
in interface GearleyResult
public EarleyParser getParser()
getParser
in interface GearleyResult
public EarleyChart getChart()
After a parse, the Earley chart isn't usually very useful. It's discarded unless the
ParserOptions.getReturnChart()
returnChart} option is enabled.
public ParseForest getForest()
GearleyResult
This method returns null
if the parse was unsuccessful.
getForest
in interface GearleyResult
public Arborist getArborist()
GearleyResult
The default arborist is created with Arborist.getArborist(ParseForest)
.
getArborist
in interface GearleyResult
public Arborist getArborist(Axe axe)
GearleyResult
The arborist is created with Arborist.getArborist(ParseForest, Axe)
.
getArborist
in interface GearleyResult
axe
- the arborists axepublic boolean isAmbiguous()
GearleyResult
isAmbiguous
in interface GearleyResult
public boolean isInfinitelyAmbiguous()
GearleyResult
The parse will only be infinitely ambiguous if the grqmmar contained a loop.
isInfinitelyAmbiguous
in interface GearleyResult
public boolean succeeded()
succeeded
in interface GearleyResult
public boolean prefixSucceeded()
Suppose you're looking for "abb" and you give "abbc" as the input. That parse will fail, but it did succeed on a prefix of the input. This method will return true if the input began with a string that could be successfully parsed.
Prefix parsing is only performed if the prefixParsing
option is
enabled.
Note: if the whole parse succeeded, this method returns false.
prefixSucceeded
in interface GearleyResult
public Token[] getSuffix()
public EarleyResult continueParsing()
If prefix parsing is enabled, and a prefix was identified, this method will attempt to continue parsing from the next token after the previous prefix parse.
continueParsing
in interface GearleyResult
ParseException
- if this result doesn't indicate that a prefix parse was successfulpublic EarleyResult continueParsing(GearleyParser newParser)
If prefix parsing is enabled, and a prefix was identified, this method will attempt to continue parsing from the next token after the previous prefix parse.
continueParsing
in interface GearleyResult
newParser
- The (next) parser.ParseException
- if this result doesn't indicate that a prefix parse was successfulpublic int getTokenCount()
In the case of an unsuccessful parse, restarting may occur before this position.
getTokenCount
in interface GearleyResult
public Token getLastToken()
In the case of an unsuccessful parse, restarting may reparse this token.
getLastToken
in interface GearleyResult
public int getOffset()
GearleyResult
getOffset
in interface GearleyResult
public int getLineNumber()
GearleyResult
getLineNumber
in interface GearleyResult
public int getColumnNumber()
GearleyResult
getColumnNumber
in interface GearleyResult
public java.util.Set<TerminalSymbol> getPredictedTerminals()
GearleyResult
getPredictedTerminals
in interface GearleyResult