private int[] calcTokenOffsets() {
    int[] offsets = new int[tokens.size()];
    int tokenStart = 0;
    for (int i = 0; i < tokens.size(); i++) {
      TokenInfo info = tokens.get(i);
      offsets[i] = tokenStart;
      tokenStart += info.length();
    }
    return offsets;
  }
private int[] calcTokenOffsets()