Package org.nineml.coffeegrinder.parser
Interface GearleyResult
- All Known Implementing Classes:
EarleyResult,GllResult
public interface GearleyResult
The result of a parse with an Earley or GLL parser.
-
Method Summary
Modifier and TypeMethodDescriptionAfter a successful prefix parse, this method continues parsing.continueParsing(GearleyParser parser) After a successful prefix parse, this method continues parsing with a new parser.Get an arborist to extract trees from the forest.getArborist(Axe axe) Get an arborist to extract trees from the forest.intReturns the column number of the last character on the last line read by the parser.Return the parse forest created by the parser.Return the last token parsed.intReturns the line number of the last line read by the parser.intReturns the last offset read by the parser.The parser used.longReturns the number of milliseconds spent parsing.Returns the symbols predicted as possibly next in the case where a parse fails.intReturn the number of tokens parsed.booleanReturns true if the parse was ambiguous.booleanReturns true if the parse was infinitely ambiguous.booleanReturns true if the parser successfully processed a prefix of the input.booleanReturns true of the parse was successful.
-
Method Details
-
getParser
GearleyParser getParser()The parser used.- Returns:
- The parser.
-
succeeded
boolean succeeded()Returns true of the parse was successful.- Returns:
- true if the parse was successful.
-
prefixSucceeded
boolean prefixSucceeded()Returns true if the parser successfully processed a prefix of the input.Note that the GLL parser does not support prefix parsing.
- Returns:
- true if a prefix of the input was parsed successfully.
-
getParseTime
long getParseTime()Returns the number of milliseconds spent parsing.- Returns:
- the number of milliseconds
-
continueParsing
GearleyResult continueParsing()After a successful prefix parse, this method continues parsing.- Returns:
- The (next) parse result.
-
continueParsing
After a successful prefix parse, this method continues parsing with a new parser.- Parameters:
parser- The (next) parser.- Returns:
- The (next) parse result.
-
getForest
ParseForest getForest()Return the parse forest created by the parser.This method returns
nullif the parse was unsuccessful.- Returns:
- The parse forest.
-
getArborist
Arborist getArborist()Get an arborist to extract trees from the forest.The default arborist is created with
Arborist.getArborist(ParseForest).- Returns:
- the arborist
-
getArborist
Get an arborist to extract trees from the forest.The arborist is created with
Arborist.getArborist(ParseForest, Axe).- Parameters:
axe- the arborists axe- Returns:
- the arborist
-
isAmbiguous
boolean isAmbiguous()Returns true if the parse was ambiguous.- Returns:
- true if the parse was ambiguous.
-
isInfinitelyAmbiguous
boolean isInfinitelyAmbiguous()Returns true if the parse was infinitely ambiguous.The parse will only be infinitely ambiguous if the grqmmar contained a loop.
- Returns:
- true if the parse was infinitely ambiguous.
-
getTokenCount
int getTokenCount()Return the number of tokens parsed.- Returns:
- the number of tokens.
-
getLastToken
Token getLastToken()Return the last token parsed.- Returns:
- The last token.
-
getOffset
int getOffset()Returns the last offset read by the parser.- Returns:
- The offset.
-
getLineNumber
int getLineNumber()Returns the line number of the last line read by the parser.- Returns:
- The line number.
-
getColumnNumber
int getColumnNumber()Returns the column number of the last character on the last line read by the parser.- Returns:
- The column number.
-
getPredictedTerminals
Set<TerminalSymbol> getPredictedTerminals()Returns the symbols predicted as possibly next in the case where a parse fails.- Returns:
- The set of terminals.
-