docs: private static boolean parse(XMLTokener x, JSONObject context,
                                   String name) throws JSONException {
          char       c;
          int        i;
          JSONObject jsonobject = null;
          String     string;
          String     tagName;
          Object     token;
  
  // Test for and skip past these forms:
  //      <!-- ... -->
  //      <!   ...   >
  //      <![  ... ]]>
  //      <?   ...  ?>
  // Report errors for these forms:
  //      <>
  //      <=
  //      <<
  
          token = x.nextToken();
  
  // <!
  
          if (token == BANG) {
              c = x.next();
              if (c == '-') {
                  if (x.next() == '-') {
                      x.skipPast("-->");
                      return false;
                  }
                  x.back();
              } else if (c == '[') {
                  token = x.nextToken();
                  if ("CDATA".equals(token)) {
                      if (x.next() == '[') {
                          string = x.nextCDATA();
                          if (string.length() > 0) {
                              context.accumulate("content", string);
                          }
                          return false;
                      }
                  }
                  throw x.syntaxError("Expected 'CDATA['");
              }
              i = 1;
              do {
                  token = x.nextMeta();
                  if (token == null) {
                      throw x.syntaxError("Missing '>' after '<!'.");
                  } else if (token == LT) {
                      i += 1;
                  } else if (token == GT) {
                      i -= 1;
                  }
              } while (i > 0);
              return false;
          } else if (token == QUEST) {
  
  // <?
  
              x.skipPast("?>");
              return false;
          } else if (token == SLASH) {
  
  // Close tag </
  
              token = x.nextToken();
              if (name == null) {
                  throw x.syntaxError("Mismatched close tag " + token);
              }
              if (!token.equals(name)) {
                  throw x.syntaxError("Mismatched " + name + " and " + token);
              }
              if (x.nextToken() != GT) {
                  throw x.syntaxError("Misshaped close tag");
              }
              return true;
  
          } else if (token instanceof Character) {
              throw x.syntaxError("Misshaped tag");
  
  // Open tag <
  
          } else {
              tagName = (String)token;
              token = null;
              jsonobject = new JSONObject();
              for (;;) {
                  if (token == null) {
                      token = x.nextToken();
                  }
  
  // attribute = value
  
                  if (token instanceof String) {
                      string = (String)token;
                      token = x.nextToken();
                      if (token == EQ) {
                          token = x.nextToken();
                          if (!(token instanceof String)) {
                              throw x.syntaxError("Missing value");
                          }
                          jsonobject.accumulate(string,
                                  XML.stringToValue((String)token));
                          token = null;
                      } else {
                          jsonobject.accumulate(string, "");
                      }
  
  // Empty tag <.../>
  
                  } else if (token == SLASH) {
                      if (x.nextToken() != GT) {
                          throw x.syntaxError("Misshaped tag");
                      }
                      if (jsonobject.length() > 0) {
                          context.accumulate(tagName, jsonobject);
                      } else {
                          context.accumulate(tagName, "");
                      }
                      return false;
  
  // Content, between <...> and </...>
  
                  } else if (token == GT) {
                      for (;;) {
                          token = x.nextContent();
                          if (token == null) {
                              if (tagName != null) {
                                  throw x.syntaxError("Unclosed tag " + tagName);
                              }
                              return false;
                          } else if (token instanceof String) {
                              string = (String)token;
                              if (string.length() > 0) {
                                  jsonobject.accumulate("content",
                                          XML.stringToValue(string));
                              }
  
  // Nested element
  
                          } else if (token == LT) {
                              if (parse(x, jsonobject, tagName)) {
                                  if (jsonobject.length() == 0) {
                                      context.accumulate(tagName, "");
                                  } else if (jsonobject.length() == 1 &&
                                         jsonobject.opt("content") != null) {
                                      context.accumulate(tagName,
                                              jsonobject.opt("content"));
                                  } else {
                                      context.accumulate(tagName, jsonobject);
                                  }
                                  return false;
                              }
                          }
                      }
                  } else {
                      throw x.syntaxError("Misshaped tag");
                  }
              }
          }
      }