code: public static FA create(FA fa, int errorSi) {
          FA cfa; // result
          int[] sorted;
          int si;
          int idx;
          int faSize;
          State faState;
          State cfaState;
          int nextChar;
          int width;
          Range range;
          int nextSi;
  
          faSize = fa.size();
          cfa = new FA();
          for (si = 0; si < faSize; si++) {
              faState = fa.get(si);
              if (cfa.add(faState.getLabel()) != si) {
                  throw new RuntimeException();
              }
              cfaState = cfa.get(si);
              if (fa.getStart() == si) {
                  cfa.setStart(si);
              }
              if (fa.isEnd(si)) {
                  cfa.setEnd(si);
              }
  
              sorted = faState.sortRanges();
              nextChar = 0;
              for (idx = 0; idx < sorted.length; idx += width) {
                  width = countConsecutive(faState, sorted, idx);
                  range = firstToLast(faState, sorted, idx, width);
                  nextSi = faState.getEnd(sorted[idx]);
                  if (nextChar < range.getFirst()) {
                      cfaState.add(errorSi, new Range((char) nextChar, (char) (range.getFirst() - 1)));
                  }
                  cfaState.add(faState.getEnd(sorted[idx]), range);
                  nextChar = range.getLast() + 1;
              }
              if (nextChar <= Character.MAX_VALUE) {
                  cfaState.add(errorSi, new Range((char) nextChar, Character.MAX_VALUE));
              }
          }
  
          return cfa;
      }
docs: The last state of the automaton returned is the error state.