Chapter 4Parsing

4.1GearleyParser

The org.nineml.coffeegrinder.parser.GearleyParser interface.

4.1.1Method summary

Public methods on the GearleyParser interface.

public int getColumnNumber()

Returns the column number of the last character on the last line read by the parser.

public ParserGrammar getGrammar()

The grammar used by this parser.

public int getLineNumber()

Returns the line number of the last line read by the parser.

public int getOffset()

Returns the last offset read by the parser.

public ParserType getParserType()

The parser type.

public NonterminalSymbol getSeed()

The seed used by this parser.

public boolean hasMoreInput()

Returns true of the parse ended without consuming all input.

public GearleyResult parse(String input)

Parse a string.

public GearleyResult parse(Iterator<Token> input)

Parse a sequence of tokens provided by an iterator.

Note that the GLL parser only parses character tokens.

public GearleyResult parse(Token[] input)

Parse an array of tokens.

Note that the GLL parser only parses character tokens.

4.2GearleyResult

The org.nineml.coffeegrinder.parser.GearleyResult interface.

4.2.1Method summary

Public methods on the GearleyResult interface.

public GearleyResult continueParsing()

After a successful prefix parse, this method continues parsing.

public GearleyResult continueParsing(GearleyParser parser)

After a successful prefix parse, this method continues parsing with a new parser.

public Arborist getArborist()

Get an arborist to extract trees from the forest.

The default arborist is created with getArborist(ParseForest).

public Arborist getArborist(Axe axe)

Get an arborist to extract trees from the forest.

The arborist is created with getArborist(ParseForest, Axe).

public int getColumnNumber()

Returns the column number of the last character on the last line read by the parser.

public ParseForest getForest()

Return the parse forest created by the parser.

This method returns null if the parse was unsuccessful.

public Token getLastToken()

Return the last token parsed.

public int getLineNumber()

Returns the line number of the last line read by the parser.

public int getOffset()

Returns the last offset read by the parser.

public long getParseTime()

Returns the number of milliseconds spent parsing.

public GearleyParser getParser()

The parser used.

public Set<TerminalSymbol> getPredictedTerminals()

Returns the symbols predicted as possibly next in the case where a parse fails.

public int getTokenCount()

Return the number of tokens parsed.

public boolean isAmbiguous()

Returns true if the parse was ambiguous.

public boolean isInfinitelyAmbiguous()

Returns true if the parse was infinitely ambiguous.

The parse will only be infinitely ambiguous if the grqmmar contained a loop.

public boolean prefixSucceeded()

Returns true if the parser successfully processed a prefix of the input.

Note that the GLL parser does not support prefix parsing.

public boolean succeeded()

Returns true of the parse was successful.