public abstract class DecisionTree extends Object
DecisionTree
describes the transition table
for a lexer Automata
cell, i.e. the shifting action
to take with respect to the next character read from the input stream.
The point of DecisionTree
is that it provides several implementations
of how these transition tables can be encoded, giving different trade-offs
depending on the shape of the transition table. The method compile(TreeMap)
is used to build a "good" decision tree from a raw transition table.
Modifier and Type | Class and Description |
---|---|
static class |
DecisionTree.Impossible
A specific implementation of
DecisionTree to represents
empty transition tables |
static class |
DecisionTree.Kind
The different kinds of available implementations of
DecisionTree |
static class |
DecisionTree.Return
An implementation of
DecisionTree which maps
some specific shifting action
to all possible characters. |
static class |
DecisionTree.Split
An implementation of
DecisionTree which represents
a binary choice with respect to some DecisionTree.Split.pivot character:
every character below or equal to the DecisionTree.Split.pivot
is mapped to the result of a recursive decision tree DecisionTree.Split.left
every character higher than the DecisionTree.Split.pivot
is mapped to the result of a recursive decision tree DecisionTree.Split.right
This implementation is used as an internal node to implement
binary decision trees. |
static class |
DecisionTree.Switch
An implementation of
DecisionTree which represents the
transition table as a switch mapping some character sets
to DFA.TransActions . |
static class |
DecisionTree.Table
An implementation of
DecisionTree which represents the transitions
from a contiguous set of characters, starting at character DecisionTree.Table.base ,
as an array of actions. |
Modifier and Type | Field and Description |
---|---|
static DecisionTree.Impossible |
IMPOSSIBLE
The decision tree for the empty transition table
|
Constructor and Description |
---|
DecisionTree() |
Modifier and Type | Method and Description |
---|---|
static DecisionTree |
compile(TreeMap<CSet,DFA.TransActions> partition) |
abstract CSet |
getDomain() |
abstract DecisionTree.Kind |
getKind() |
static void |
main(String[] args)
Functional tests of decision trees and
compile(TreeMap) |
static DecisionTree.Return |
ret(DFA.TransActions transActions) |
static DecisionTree |
simplify(DecisionTree tree)
This method tries to simplify the given tree in order to
obtain an equivalent decision tree by removing useless
parts.
|
static DecisionTree |
split(char pivot,
DecisionTree left,
DecisionTree right) |
static DecisionTree |
switchTable(TreeMap<CSet,DFA.TransActions> table) |
static DecisionTree |
tabulated(char base,
@NonNull DFA.TransActions[] table) |
String |
toString() |
public static final DecisionTree.Impossible IMPOSSIBLE
public abstract CSet getDomain()
public abstract DecisionTree.Kind getKind()
public static final DecisionTree.Return ret(DFA.TransActions transActions)
transActions
- transActions
in response to any characterpublic static final DecisionTree split(char pivot, DecisionTree left, DecisionTree right)
pivot
- left
- right
- left
or right
depending on their position relative to pivot
public static final DecisionTree switchTable(TreeMap<CSet,DFA.TransActions> table)
table
- table
as a switch between character setspublic static final DecisionTree tabulated(char base, @NonNull DFA.TransActions[] table)
base
- table
- base
and base
+ table.length
, as given
by table
public static DecisionTree simplify(DecisionTree tree)
tree
- tree
public static DecisionTree compile(TreeMap<CSet,DFA.TransActions> partition)
partition
- a transition table for a lexer's automaton cell,
mapping sets of characters to the associated shifting actionpartition
in a hopefully concise and efficient waypublic static void main(String[] args)
compile(TreeMap)
args
-