Class RBBITableBuilder

java.lang.Object
com.ibm.icu.text.RBBITableBuilder

class RBBITableBuilder extends 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.
  • Field Details

    • fRB

      private RBBIRuleBuilder fRB
    • fRootIx

      private int fRootIx
      The array index into RBBIRuleBuilder.fTreeRoots for the parse tree to operate on.
    • fDStates

      D states (Aho's terminology). Index is state number.
    • fSafeTable

      private 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:
    • 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 Details

  • Method Details

    • buildForwardTable

      void buildForwardTable()
    • calcNullable

      void calcNullable(RBBINode n)
    • calcFirstPos

      void calcFirstPos(RBBINode n)
    • calcLastPos

      void calcLastPos(RBBINode n)
    • calcFollowPos

      void calcFollowPos(RBBINode n)
    • addRuleRootNodes

      void addRuleRootNodes(List<RBBINode> dest, RBBINode node)
    • calcChainedFollowPos

      void calcChainedFollowPos(RBBINode tree, RBBINode endMarkNode)
    • 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

      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

      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(Collection<RBBINode> s)
    • printStates

      void printStates()
    • printReverseTable

      void printReverseTable()
      Debug Function. Dump the fully constructed safe reverse table.
    • printRuleStatusTable

      void printRuleStatusTable()