Package com.ibm.icu.text
Class RBBITableBuilder
- java.lang.Object
-
- com.ibm.icu.text.RBBITableBuilder
-
class RBBITableBuilder extends java.lang.Object
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 Classes Modifier and Type Class Description (package private) static class
RBBITableBuilder.RBBIStateDescriptor
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<RBBITableBuilder.RBBIStateDescriptor>
fDStates
D states (Aho's terminology).(package private) int
fLASlotsInUse
Counter used when assigning lookahead rule numbers.(package private) int[]
fLookAheadRuleMap
Map from rule number (fVal in look ahead nodes) to sequential lookahead index.private RBBIRuleBuilder
fRB
private int
fRootIx
The array index into RBBIRuleBuilder.fTreeRoots for the parse tree to operate on.private java.util.List<short[]>
fSafeTable
Synthesized safe table, a List of row arrays.private static int
MAX_STATE_FOR_8BITS_TABLE
-
Constructor Summary
Constructors Constructor Description RBBITableBuilder(RBBIRuleBuilder rb, int rootNodeIx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addRuleRootNodes(java.util.List<RBBINode> dest, RBBINode node)
(package private) void
bofFixup()
(package private) void
buildForwardTable()
(package private) void
buildSafeReverseTable()
Synthesize a safe state table from the main state table.(package private) void
buildStateTable()
(package private) void
calcChainedFollowPos(RBBINode tree, RBBINode endMarkNode)
(package private) void
calcFirstPos(RBBINode n)
(package private) void
calcFollowPos(RBBINode n)
(package private) void
calcLastPos(RBBINode n)
(package private) void
calcNullable(RBBINode n)
(package private) RBBIDataWrapper.RBBIStateTable
exportSafeTable()
Create a RBBIDataWrapper.RBBIStateTable for the safe reverse table.(package private) RBBIDataWrapper.RBBIStateTable
exportTable()
Create a RBBIDataWrapper.RBBIStateTable for a newly compiled table.(package private) boolean
findDuplCharClassFrom(RBBIRuleBuilder.IntPair categories)
Find duplicate (redundant) character classes.(package private) boolean
findDuplicateSafeState(RBBIRuleBuilder.IntPair states)
Find the next duplicate state in the safe reverse table.(package private) boolean
findDuplicateState(RBBIRuleBuilder.IntPair states)
Find duplicate (redundant) states, beginning at the specified pair, within this state table.(package private) void
flagAcceptingStates()
(package private) void
flagLookAheadStates()
(package private) void
flagTaggedStates()
(package private) int
getSafeTableSize()
Calculate the size of the runtime form of this safe state table.(package private) int
getTableSize()
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()
mapLookAheadRules(package private) void
mergeRuleStatusVals()
(package private) void
printPosSets(RBBINode n)
(package private) void
printReverseTable()
Debug Function.(package private) void
printRuleStatusTable()
(package private) void
printSet(java.util.Collection<RBBINode> s)
(package private) void
printStates()
(package private) void
removeColumn(int column)
Remove a column from the state table.(package private) int
removeDuplicateStates()
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 Detail
-
fRB
private RBBIRuleBuilder fRB
-
fRootIx
private int fRootIx
The array index into RBBIRuleBuilder.fTreeRoots for the parse tree to operate on.
-
fDStates
private java.util.List<RBBITableBuilder.RBBIStateDescriptor> fDStates
D states (Aho's terminology). Index is state number.
-
fSafeTable
private java.util.List<short[]> 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:
- Constant Field Values
-
fLookAheadRuleMap
int[] fLookAheadRuleMap
Map from rule number (fVal in look ahead nodes) to sequential lookahead index.
-
fLASlotsInUse
int fLASlotsInUse
Counter 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 Detail
-
RBBITableBuilder
RBBITableBuilder(RBBIRuleBuilder rb, int rootNodeIx)
-
-
Method Detail
-
buildForwardTable
void buildForwardTable()
-
calcNullable
void calcNullable(RBBINode n)
-
calcFirstPos
void calcFirstPos(RBBINode n)
-
calcLastPos
void calcLastPos(RBBINode n)
-
calcFollowPos
void calcFollowPos(RBBINode n)
-
bofFixup
void bofFixup()
-
buildStateTable
void buildStateTable()
-
mapLookAheadRules
void mapLookAheadRules()
mapLookAheadRules
-
flagAcceptingStates
void flagAcceptingStates()
-
flagLookAheadStates
void flagLookAheadStates()
-
flagTaggedStates
void flagTaggedStates()
-
mergeRuleStatusVals
void mergeRuleStatusVals()
-
printPosSets
void printPosSets(RBBINode n)
-
findDuplCharClassFrom
boolean findDuplCharClassFrom(RBBIRuleBuilder.IntPair categories)
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
boolean findDuplicateState(RBBIRuleBuilder.IntPair states)
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
boolean findDuplicateSafeState(RBBIRuleBuilder.IntPair states)
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
void removeState(RBBIRuleBuilder.IntPair duplStates)
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
void removeSafeState(RBBIRuleBuilder.IntPair duplStates)
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
void printSet(java.util.Collection<RBBINode> s)
-
printStates
void printStates()
-
printReverseTable
void printReverseTable()
Debug Function. Dump the fully constructed safe reverse table.
-
printRuleStatusTable
void printRuleStatusTable()
-
-