Package org.nineml.coffeegrinder.trees
Class PrintStreamTreeBuilder
java.lang.Object
org.nineml.coffeegrinder.trees.PrintStreamTreeBuilder
- All Implemented Interfaces:
TreeBuilder
- Direct Known Subclasses:
StdoutTreeBuilder
A tree builder that sends serialized results to a print stream.
-
Constructor Summary
ConstructorsConstructorDescriptionPrintStreamTreeBuilder(PrintStream stream) PrintStreamTreeBuilder(PrintStream stream, boolean addTrailingNewline) -
Method Summary
Modifier and TypeMethodDescriptionvoidendAmbiguity(int id, int leftExtent, int rightExtent) Called at the end of an ambiguity that is not marked by a single nonterminal.voidendNonterminal(NonterminalSymbol symbol, Map<String, String> attributes, int leftExtent, int rightExtent) Called when a nonterminal ends.voidendTree(boolean ambiguous, boolean absolutelyAmbiguous, boolean infinitelyAmbiguous) Called last, when construction finishes.voidstartAmbiguity(int id, int leftExtent, int rightExtent) Called at the start of an ambiguity that is not marked by a single nonterminal.voidstartNonterminal(NonterminalSymbol symbol, Map<String, String> attributes, int leftExtent, int rightExtent) Called when a new nonterminal begins.voidCalled first, when construction begins.voidCalled when a terminal occurs.
-
Constructor Details
-
PrintStreamTreeBuilder
-
PrintStreamTreeBuilder
-
-
Method Details
-
startTree
public void startTree()Description copied from interface:TreeBuilderCalled first, when construction begins.- Specified by:
startTreein interfaceTreeBuilder
-
endTree
public void endTree(boolean ambiguous, boolean absolutelyAmbiguous, boolean infinitelyAmbiguous) Description copied from interface:TreeBuilderCalled last, when construction finishes.- Specified by:
endTreein interfaceTreeBuilder- Parameters:
ambiguous- was the parse ambiguous?absolutelyAmbiguous- is the graph ambiguous?infinitelyAmbiguous- is the graph infinitely ambiguous?
-
startNonterminal
public void startNonterminal(NonterminalSymbol symbol, Map<String, String> attributes, int leftExtent, int rightExtent) Description copied from interface:TreeBuilderCalled when a new nonterminal begins.- Specified by:
startNonterminalin interfaceTreeBuilder- Parameters:
symbol- The symbol.attributes- Its attributes.leftExtent- The starting position in the input.rightExtent- The ending position in the input.
-
endNonterminal
public void endNonterminal(NonterminalSymbol symbol, Map<String, String> attributes, int leftExtent, int rightExtent) Description copied from interface:TreeBuilderCalled when a nonterminal ends.- Specified by:
endNonterminalin interfaceTreeBuilder- Parameters:
symbol- The symbol.attributes- Its attributes.leftExtent- The starting position in the input.rightExtent- The ending position in the input.
-
token
Description copied from interface:TreeBuilderCalled when a terminal occurs.- Specified by:
tokenin interfaceTreeBuilder- Parameters:
token- The terminal token.attributes- Its attributes.leftExtent- The starting position in the input.rightExtent- The ending position in the input.
-
startAmbiguity
public void startAmbiguity(int id, int leftExtent, int rightExtent) Description copied from interface:TreeBuilderCalled at the start of an ambiguity that is not marked by a single nonterminal.The ambiguity id will distinguish this ambiguity from any other ambiguity. The numbers are not sequential or guaranteed stable across parses.
- Specified by:
startAmbiguityin interfaceTreeBuilder- Parameters:
id- The ambiguity id.leftExtent- The starting position in the input.rightExtent- The ending position in the input.
-
endAmbiguity
public void endAmbiguity(int id, int leftExtent, int rightExtent) Description copied from interface:TreeBuilderCalled at the end of an ambiguity that is not marked by a single nonterminal.- Specified by:
endAmbiguityin interfaceTreeBuilder- Parameters:
id- The ambiguity id.leftExtent- The starting position in the input.rightExtent- The ending position in the input.
-