Package org.nineml.coffeegrinder.trees
Interface TreeSelector
public interface TreeSelector
The tree selector is responsible for choosing among ambiguous parses.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
endNonterminal
(NonterminalSymbol symbol, Map<String, String> attributes, int leftExtent, int rightExtent) Enda a nonterminal.boolean
Did the tree selector make an arbitrary choice?void
reset()
Reset the state of the tree selector.Make a selection.void
startNonterminal
(NonterminalSymbol symbol, Map<String, String> attributes, int leftExtent, int rightExtent) Start a nonterminal.
-
Method Details
-
getMadeAmbiguousChoice
boolean getMadeAmbiguousChoice()Did the tree selector make an arbitrary choice?A non-arbitrary choice, resolved by priority or some other mechanism does not necessarily count as an ambiguous choice.
- Returns:
- True if the selector made an arbitrary choice.
-
startNonterminal
void startNonterminal(NonterminalSymbol symbol, Map<String, String> attributes, int leftExtent, int rightExtent) Start a nonterminal.The start and end nonterminal methods allow the tree selector to track what choices have already been made.
- Parameters:
symbol
- The symbol.attributes
- Its attributes.leftExtent
- The starting position in the input.rightExtent
- The ending position in the input.
-
endNonterminal
void endNonterminal(NonterminalSymbol symbol, Map<String, String> attributes, int leftExtent, int rightExtent) Enda a nonterminal.The start and end nonterminal methods allow the tree selector to track what choices have already been made.
- Parameters:
symbol
- The symbol.attributes
- Its attributes.leftExtent
- The starting position in the input.rightExtent
- The ending position in the input.
-
select
Make a selection.The list of choices will always contain at least one choice. The list of otherChoices will include any choices previously made. The method must return a choice.
- Parameters:
choices
- The available, unused choices.otherChoices
- The available, but previously selected choices.- Returns:
- The selected choice.
-
reset
void reset()Reset the state of the tree selector.
-