public class ParseForest
extends java.lang.Object
The SPPF is a graph representation of all the (possibly infinite) parses that can be used to recognize the input sequence as a sentence in the grammar.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
logcategory |
Constructor and Description |
---|
ParseForest(ParserOptions options) |
Modifier and Type | Method and Description |
---|---|
java.util.List<ForestNode> |
getAmbiguousNodes() |
java.util.List<ForestNode> |
getNodes()
Get the nodes in the graph.
|
ParserOptions |
getOptions()
Get the options for this forest.
|
int |
getParseTreeCount()
How many parse trees are there in this forest?
|
ForestNode |
getRoot() |
boolean |
isAmbiguous()
Is the grammar represented by this graph ambiguous?
|
boolean |
isInfinitelyAmbiguous()
Is the grammar represented by this graph infinitely ambiguous?
|
java.lang.String |
serialize()
Serialize the graph as XML.
|
void |
serialize(java.io.PrintStream stream)
Serialize the graph as XML.
|
void |
serialize(java.lang.String filename)
Serialize the graph as XML.
|
int |
size()
How big is the graph?
|
public static final java.lang.String logcategory
public ParseForest(ParserOptions options)
public boolean isAmbiguous()
A grammar is ambiguous if there are more than two parses that will recognize the input.
public boolean isInfinitelyAmbiguous()
If the answer is "true", then the graph is infinitely ambiguous. If the graph is ambiguous and the anwer is "false", then all that can be said is the single parse explored to check ambiguity did not encounter infinite ambiguity. It is not an assertion that no unexplored part of the graph contains a loop.
public int getParseTreeCount()
In an infinitely ambiguous graph, there are an infinite number of parse trees. However, CoffeeGrinder will never follow the same edge twice when constructing a tree, it won't loop. So the number of available trees is always a finite number.
public java.util.List<ForestNode> getAmbiguousNodes()
public int size()
public java.util.List<ForestNode> getNodes()
public ForestNode getRoot()
public ParserOptions getOptions()
public java.lang.String serialize()
public void serialize(java.io.PrintStream stream)
stream
- the stream on which to write the XML serializationpublic void serialize(java.lang.String filename)
This method attempts to write the XML to a file.
filename
- the name of the fileForestException
- if a error occurs attempt to write to the file