private void buildBackwardsStateTable(Vector<String> tempRuleList){
  tempStateTable=new Vector<>();
  tempStateTable.addElement(new short[numCategories + 1]);
  tempStateTable.addElement(new short[numCategories + 1]);
  for (int i=0; i < tempRuleList.size(); i++) {
    String rule=tempRuleList.elementAt(i);
    if (rule.charAt(0) == '!') {
      parseRule(rule.substring(1),false);
    }
  }
  backfillLoopingStates();
  int backTableOffset=tempStateTable.size();
  if (backTableOffset > 2) {
    ++backTableOffset;
  }
  for (int i=0; i < numCategories + 1; i++)   tempStateTable.addElement(new short[numCategories + 1]);
  short[] state=tempStateTable.elementAt(backTableOffset - 1);
  for (int i=0; i < numCategories; i++)   state[i]=(short)(i + backTableOffset);
  int numRows=stateTable.length / numCategories;
  for (int column=0; column < numCategories; column++) {
    for (int row=0; row < numRows; row++) {
      int nextRow=lookupState(row,column);
      if (nextRow != 0) {
        for (int nextColumn=0; nextColumn < numCategories; nextColumn++) {
          int cellValue=lookupState(nextRow,nextColumn);
          if (cellValue != 0) {
            state=tempStateTable.elementAt(nextColumn + backTableOffset);
            state[column]=(short)(column + backTableOffset);
          }
        }
      }
    }
  }
  if (backTableOffset > 1) {
    state=tempStateTable.elementAt(1);
    for (int i=backTableOffset - 1; i < tempStateTable.size(); i++) {
      short[] state2=tempStateTable.elementAt(i);
      for (int j=0; j < numCategories; j++) {
        if (state[j] != 0 && state2[j] != 0) {
          state2[j]=state[j];
        }
      }
    }
    state=tempStateTable.elementAt(backTableOffset - 1);
    for (int i=1; i < backTableOffset - 1; i++) {
      short[] state2=tempStateTable.elementAt(i);
      if ((state2[numCategories] & END_STATE_FLAG) == 0) {
        for (int j=0; j < numCategories; j++) {
          if (state2[j] == 0) {
            state2[j]=state[j];
          }
        }
      }
    }
  }
  finishBuildingStateTable(false);
}

private void buildBackwardsStateTable ( Vector < String > tempRuleList ) { tempStateTable = new Vector < > ( ) ; tempStateTable . addElement ( new short [ numCategories + 1 ] ) ; tempStateTable . addElement ( new short [ numCategories + 1 ] ) ; for ( int i = 0 ; i < tempRuleList . size ( ) ; i ++ ) { String rule = tempRuleList . elementAt ( i ) ; if ( rule . charAt ( 0 ) == '!' ) { parseRule ( rule . substring ( 1 ) , false ) ; } } backfillLoopingStates ( ) ; int backTableOffset = tempStateTable . size ( ) ; if ( backTableOffset > 2 ) { ++ backTableOffset ; } for ( int i = 0 ; i < numCategories + 1 ; i ++ ) tempStateTable . addElement ( new short [ numCategories + 1 ] ) ; short [ ] state = tempStateTable . elementAt ( backTableOffset - 1 ) ; for ( int i = 0 ; i < numCategories ; i ++ ) state [ i ] = ( short ) ( i + backTableOffset ) ; int numRows = stateTable . length / numCategories ; for ( int column = 0 ; column < numCategories ; column ++ ) { for ( int row = 0 ; row < numRows ; row ++ ) { int nextRow = lookupState ( row , column ) ; if ( nextRow != 0 ) { for ( int nextColumn = 0 ; nextColumn < numCategories ; nextColumn ++ ) { int cellValue = lookupState ( nextRow , nextColumn ) ; if ( cellValue != 0 ) { state = tempStateTable . elementAt ( nextColumn + backTableOffset ) ; state [ column ] = ( short ) ( column + backTableOffset ) ; } } } } } if ( backTableOffset > 1 ) { state = tempStateTable . elementAt ( 1 ) ; for ( int i = backTableOffset - 1 ; i < tempStateTable . size ( ) ; i ++ ) { short [ ] state2 = tempStateTable . elementAt ( i ) ; for ( int j = 0 ; j < numCategories ; j ++ ) { if ( state [ j ] != 0 && state2 [ j ] != 0 ) { state2 [ j ] = state [ j ] ; } } } state = tempStateTable . elementAt ( backTableOffset - 1 ) ; for ( int i = 1 ; i < backTableOffset - 1 ; i ++ ) { short [ ] state2 = tempStateTable . elementAt ( i ) ; if ( ( state2 [ numCategories ] & END_STATE_FLAG ) == 0 ) { for ( int j = 0 ; j < numCategories ; j ++ ) { if ( state2 [ j ] == 0 ) { state2 [ j ] = state [ j ] ; } } } } } finishBuildingStateTable ( false ) ; }
this function builds the backward state table from the forward state table and any additional rules ( identified by the ! on the front ) supplied in the description
