Class ParseForest
- Direct Known Subclasses:
ParseForestGLL
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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetNodes()Get the nodes in the graph.Get the options for this forest.intHow many parse trees are there in this forest?getRoot()booleanIs the grammar represented by this graph ambiguous?booleanIs the grammar represented by this graph infinitely ambiguous?Serialize the graph as XML.voidserialize(PrintStream stream) Serialize the graph as XML.voidSerialize the graph as XML.intsize()How big is the graph?
-
Field Details
-
logcategory
- See Also:
-
-
Constructor Details
-
ParseForest
-
-
Method Details
-
isAmbiguous
public boolean isAmbiguous()Is the grammar represented by this graph ambiguous?A grammar is ambiguous if there are more than two parses that will recognize the input.
- Returns:
- true if the grammar is ambiguous
-
isInfinitelyAmbiguous
public boolean isInfinitelyAmbiguous()Is the grammar represented by this graph infinitely ambiguous?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.
- Returns:
- true if the parse forest is known to be infinitely ambiguous
-
getParseTreeCount
public int getParseTreeCount()How many parse trees are there in this forest?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.
- Returns:
- the parse tree count
-
getAmbiguousNodes
-
size
public int size()How big is the graph?- Returns:
- the number of nodes in the graph
-
getNodes
Get the nodes in the graph.- Returns:
- the nodes in the graph.
-
getRoot
-
getOptions
Get the options for this forest.- Returns:
- the options.
-
serialize
Serialize the graph as XML.- Returns:
- an XML serialization as a string
-
serialize
Serialize the graph as XML.- Parameters:
stream- the stream on which to write the XML serialization
-
serialize
Serialize the graph as XML.This method attempts to write the XML to a file.
- Parameters:
filename- the name of the file- Throws:
ForestException- if a error occurs attempt to write to the file
-