private RuntimeException err(String msg) {
    // We can't tell if EOF was hit by comparing start<=end
    // because the illegal char could have been the last in the buffer
    // or in the stream.  To deal with this, the "eof" var was introduced
    if (!eof && start>0) start--;  // backup one char
    String chs = "char=" + ((start>=end) ? "(EOF)" : "" + (char)buf[start]);
    String pos = "position=" + (gpos+start);
    String tot = chs + ',' + pos;
    if (msg==null) {
      if (start>=end) msg = "Unexpected EOF";
      else msg="JSON Parse Error";
    }
    return new RuntimeException(msg + ": " + tot);
  }