private static String getErrorMessage(TokenList tokens, Token parentToken, Token offender, String[] legalParents) {
    String tokenName=tokens.getTokenizer().getTokenName(offender);
    if (parentToken==null){
      StringBuilder sb=new StringBuilder();
      sb.append(tokenName);
      sb.append(" tag should be nested in one of the following: ");
      if (legalParents==null)
        sb.append(" [INTERNAL ERROR, please report: legal parents not noted]");
      else 
        sb.append(new DelimitedString(", ").addEach(legalParents));
      return sb.toString();
    }
    else
      return tokenName
          +" tag cannot appear inside of "
          +tokens.getTokenizer().getTokenName(parentToken)+" tag";
  }