Package com.ibm.icu.text
Class RBBITableBuilder
java.lang.Object
com.ibm.icu.text.RBBITableBuilder
This class is part of the RBBI rule compiler.
It builds the state transition table used by the RBBI runtime
from the expression syntax tree generated by the rule scanner.
This class is part of the RBBI implementation only.
There is no user-visible public API here.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
<RBBITableBuilder.RBBIStateDescriptor> D states (Aho's terminology).(package private) int
Counter used when assigning lookahead rule numbers.(package private) int[]
Map from rule number (fVal in look ahead nodes) to sequential lookahead index.private RBBIRuleBuilder
private int
The array index into RBBIRuleBuilder.fTreeRoots for the parse tree to operate on.private List
<short[]> Synthesized safe table, a List of row arrays.private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
addRuleRootNodes
(List<RBBINode> dest, RBBINode node) (package private) void
bofFixup()
(package private) void
(package private) void
Synthesize a safe state table from the main state table.(package private) void
(package private) void
calcChainedFollowPos
(RBBINode tree, RBBINode endMarkNode) (package private) void
(package private) void
(package private) void
(package private) void
(package private) RBBIDataWrapper.RBBIStateTable
Create a RBBIDataWrapper.RBBIStateTable for the safe reverse table.(package private) RBBIDataWrapper.RBBIStateTable
Create a RBBIDataWrapper.RBBIStateTable for a newly compiled table.(package private) boolean
findDuplCharClassFrom
(RBBIRuleBuilder.IntPair categories) Find duplicate (redundant) character classes.(package private) boolean
Find the next duplicate state in the safe reverse table.(package private) boolean
Find duplicate (redundant) states, beginning at the specified pair, within this state table.(package private) void
(package private) void
(package private) void
(package private) int
Calculate the size of the runtime form of this safe state table.(package private) int
Calculate the size in bytes of the serialized form of this state transition table, which is identical to the ICU4C runtime form.(package private) void
mapLookAheadRules(package private) void
(package private) void
(package private) void
Debug Function.(package private) void
(package private) void
(package private) void
(package private) void
removeColumn
(int column) Remove a column from the state table.(package private) int
Check for, and remove duplicate states (table rows).(package private) void
removeSafeState
(RBBIRuleBuilder.IntPair duplStates) Remove a duplicate state from the safe table.(package private) void
removeState
(RBBIRuleBuilder.IntPair duplStates) Remove a duplicate state (row) from the state table.
-
Field Details
-
fRB
-
fRootIx
private int fRootIxThe array index into RBBIRuleBuilder.fTreeRoots for the parse tree to operate on. -
fDStates
D states (Aho's terminology). Index is state number. -
fSafeTable
Synthesized safe table, a List of row arrays. -
MAX_STATE_FOR_8BITS_TABLE
private static final int MAX_STATE_FOR_8BITS_TABLE- See Also:
-
fLookAheadRuleMap
int[] fLookAheadRuleMapMap from rule number (fVal in look ahead nodes) to sequential lookahead index. -
fLASlotsInUse
int fLASlotsInUseCounter used when assigning lookahead rule numbers. Contains the last look-ahead number already in use. The first look-ahead number is 2; Number 1 (ACCEPTING_UNCONDITIONAL) is reserved for non-lookahead accepting states. See the declarations of RBBIStateTableRowT.
-
-
Constructor Details
-
RBBITableBuilder
RBBITableBuilder(RBBIRuleBuilder rb, int rootNodeIx)
-
-
Method Details
-
buildForwardTable
void buildForwardTable() -
calcNullable
-
calcFirstPos
-
calcLastPos
-
calcFollowPos
-
addRuleRootNodes
-
calcChainedFollowPos
-
bofFixup
void bofFixup() -
buildStateTable
void buildStateTable() -
mapLookAheadRules
void mapLookAheadRules()mapLookAheadRules -
flagAcceptingStates
void flagAcceptingStates() -
flagLookAheadStates
void flagLookAheadStates() -
flagTaggedStates
void flagTaggedStates() -
mergeRuleStatusVals
void mergeRuleStatusVals() -
printPosSets
-
findDuplCharClassFrom
Find duplicate (redundant) character classes. Begin looking with categories.first. Duplicates, if found are returned in the categories parameter. This is an iterator-like function, used to identify character classes (state table columns) that can be eliminated.- Parameters:
categories
- in/out parameter, specifies where to start looking for duplicates, and returns the first pair of duplicates found, if any.- Returns:
- true if duplicate char classes were found, false otherwise.
-
removeColumn
void removeColumn(int column) Remove a column from the state table. Used when two character categories have been found equivalent, and merged together, to eliminate the unneeded table column. -
findDuplicateState
Find duplicate (redundant) states, beginning at the specified pair, within this state table. This is an iterator-like function, used to identify states (state table rows) that can be eliminated.- Parameters:
states
- in/out parameter, specifies where to start looking for duplicates, and returns the first pair of duplicates found, if any.- Returns:
- true if duplicate states were found, false otherwise.
-
findDuplicateSafeState
Find the next duplicate state in the safe reverse table. An iterator function.- Parameters:
states
- in/out parameter, specifies where to start looking for duplicates, and returns the first pair of duplicates found, if any.- Returns:
- true if duplicate states were found, false otherwise.
-
removeState
Remove a duplicate state (row) from the state table. All references to the deleted (second) state are redirected to first state.- Parameters:
duplStates
- The duplicate pair of states.
-
removeSafeState
Remove a duplicate state from the safe table.- Parameters:
duplStates
- The duplicate pair of states. The first is kept, the second is removed. All references to the second in the state table are retargeted to the first.
-
removeDuplicateStates
int removeDuplicateStates()Check for, and remove duplicate states (table rows).- Returns:
- the number of states removed.
-
getTableSize
int getTableSize()Calculate the size in bytes of the serialized form of this state transition table, which is identical to the ICU4C runtime form. Refer to common/rbbidata.h from ICU4C for the declarations of the structures being matched by this calculation. -
exportTable
RBBIDataWrapper.RBBIStateTable exportTable()Create a RBBIDataWrapper.RBBIStateTable for a newly compiled table. RBBIDataWrapper.RBBIStateTable is similar to struct RBBIStateTable in ICU4C, in common/rbbidata.h -
buildSafeReverseTable
void buildSafeReverseTable()Synthesize a safe state table from the main state table. -
getSafeTableSize
int getSafeTableSize()Calculate the size of the runtime form of this safe state table. -
exportSafeTable
RBBIDataWrapper.RBBIStateTable exportSafeTable()Create a RBBIDataWrapper.RBBIStateTable for the safe reverse table. RBBIDataWrapper.RBBIStateTable is similar to struct RBBIStateTable in ICU4C, in common/rbbidata.h -
printSet
-
printStates
void printStates() -
printReverseTable
void printReverseTable()Debug Function. Dump the fully constructed safe reverse table. -
printRuleStatusTable
void printRuleStatusTable()
-