code: private static boolean processAtomLabels(final CharIter iter, final Map<Integer, String> dest) {
          int atomIdx = 0;
          while (iter.hasNext()) {
  
              // fast forward through empty labels
              while (iter.nextIf(';'))
                  atomIdx++;
  
              char c = iter.next();
              if (c == '$') {
                  iter.nextIf(','); // optional
                  // end of atom label
                  return true;
              } else {
                  iter.pos--; // push back
                  int beg = iter.pos;
                  int rollback = beg;
                  while (iter.hasNext()) {
  
                      if (iter.pos == beg && iter.curr() == '_' &&
                          iter.peek() == 'R') {
                          ++beg;
                      }
  
                      // correct step over of escaped label
                      if (iter.curr() == '&') {
                          rollback = iter.pos;
                          if (iter.nextIf('&') && iter.nextIf('#') && iter.nextIfDigit()) {
                              while (iter.nextIfDigit()){} // more digits
                              if (!iter.nextIf(';')) {
                                  iter.pos = rollback;
                              } else {
                              }
                          } else {
                              iter.pos = rollback;
                          }
                      }
                      else if (iter.curr() == ';')
                          break;
                      else if (iter.curr() == '$')
                          break;
                      else
                          iter.next();
                  }
                  dest.put(atomIdx, unescape(iter.substr(beg, iter.pos)));
                  atomIdx++;
                  if (iter.nextIf('$')) {
                      iter.nextIf(','); // optional
                      return true;
                  }
                  if (!iter.nextIf(';'))
                      return false;
              }
          }
          return false;
      }
docs: Process atom labels from extended SMILES in a char iter.
  
  @param iter char iteration
  @param dest destination of labels (atomidx->label)
  @return parse success/failure