Package org.nineml.coffeegrinder.gll
Class GllParser
- java.lang.Object
-
- org.nineml.coffeegrinder.gll.GllParser
-
- All Implemented Interfaces:
GearleyParser
public class GllParser extends java.lang.Object implements GearleyParser
The GLL parser.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.)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringgllexecutionThe logging category for the log messages about the execution of the GLL parser.ParserGrammargrammarThe grammar.static java.lang.StringlogcategoryThe logging category for log messages about the GLL parser.
-
Constructor Summary
Constructors Constructor Description GllParser(ParserGrammar grammar, ParserOptions options)Construct a GLL parser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetColumnNumber()Returns the column number of the last character on the last line read by the parser.intgetDefaultPriority()The default priority.ParserGrammargetGrammar()The grammar used by this parser.intgetLineNumber()Returns the line number of the last line read by the parser.intgetOffset()Returns the last offset read by the parser.ParserTypegetParserType()The parser type.java.lang.StringgetPriorityStyle()The priority style.NonterminalSymbolgetSeed()The seed used by this parser.Token[]getTokens()Return the tokens used in the parse.booleanhasMoreInput()Returns true of the parse ended without consuming all input.GllResultparse(java.lang.String input)Parse a string.GllResultparse(java.util.Iterator<Token> input)Parse a sequence of tokens provided by an iterator.GllResultparse(Token[] input)Parse an array of tokens.booleansucceeded()Did the parse succeed?
-
-
-
Field Detail
-
logcategory
public static final java.lang.String logcategory
The logging category for log messages about the GLL parser.- See Also:
- Constant Field Values
-
gllexecution
public static final java.lang.String gllexecution
The logging category for the log messages about the execution of the GLL parser.- See Also:
- Constant Field Values
-
grammar
public final ParserGrammar grammar
The grammar.
-
-
Constructor Detail
-
GllParser
public GllParser(ParserGrammar grammar, ParserOptions options)
Construct a GLL parser.- Parameters:
grammar- the grammar.options- the options.
-
-
Method Detail
-
parse
public GllResult parse(Token[] input)
Description copied from interface:GearleyParserParse an array of tokens.Note that the GLL parser only parses character tokens.
- Specified by:
parsein interfaceGearleyParser- Parameters:
input- The array of tokens.- Returns:
- The parse result.
-
parse
public GllResult parse(java.util.Iterator<Token> input)
Description copied from interface:GearleyParserParse a sequence of tokens provided by an iterator.Note that the GLL parser only parses character tokens.
- Specified by:
parsein interfaceGearleyParser- Parameters:
input- The token iterator.- Returns:
- The parse result.
-
parse
public GllResult parse(java.lang.String input)
Description copied from interface:GearleyParserParse a string.- Specified by:
parsein interfaceGearleyParser- Parameters:
input- The input string.- Returns:
- The parse result.
-
succeeded
public boolean succeeded()
Did the parse succeed?Is the parse finished and did it find at least one parse?
- Returns:
- true if it did.
-
getTokens
public Token[] getTokens()
Return the tokens used in the parse.- Returns:
- the tokens.
-
getParserType
public ParserType getParserType()
Description copied from interface:GearleyParserThe parser type.- Specified by:
getParserTypein interfaceGearleyParser- Returns:
- The parser type.
-
getPriorityStyle
public java.lang.String getPriorityStyle()
Description copied from interface:GearleyParserThe priority style.Meaningless if priorities are not used in the grammar.
- Specified by:
getPriorityStylein interfaceGearleyParser- Returns:
- The priority style.
-
getDefaultPriority
public int getDefaultPriority()
Description copied from interface:GearleyParserThe default priority.Meaningless if priorities are not used in the grammar.
- Specified by:
getDefaultPriorityin interfaceGearleyParser- Returns:
- The default priority.
-
getGrammar
public ParserGrammar getGrammar()
Description copied from interface:GearleyParserThe grammar used by this parser.- Specified by:
getGrammarin interfaceGearleyParser- Returns:
- The grammar.
-
getSeed
public NonterminalSymbol getSeed()
Description copied from interface:GearleyParserThe seed used by this parser.- Specified by:
getSeedin interfaceGearleyParser- Returns:
- The seed token for this parse.
-
hasMoreInput
public boolean hasMoreInput()
Description copied from interface:GearleyParserReturns true of the parse ended without consuming all input.- Specified by:
hasMoreInputin interfaceGearleyParser- Returns:
- true if there was more input.
-
getOffset
public int getOffset()
Description copied from interface:GearleyParserReturns the last offset read by the parser.- Specified by:
getOffsetin interfaceGearleyParser- Returns:
- the offset.
-
getLineNumber
public int getLineNumber()
Description copied from interface:GearleyParserReturns the line number of the last line read by the parser.- Specified by:
getLineNumberin interfaceGearleyParser- Returns:
- the line number.
-
getColumnNumber
public int getColumnNumber()
Description copied from interface:GearleyParserReturns the column number of the last character on the last line read by the parser.- Specified by:
getColumnNumberin interfaceGearleyParser- Returns:
- the column number.
-
-