public static Cons parseTokenizerCharacterSpec(Stella_Object characterspec, List allcharactersets) {
    { Cons charset = Stella.NIL;
      Cons complementset = Stella.NIL;
      Cons parsedspec = null;

      { Surrogate testValue000 = Stella_Object.safePrimaryType(characterspec);

        if (Surrogate.subtypeOfStringP(testValue000)) {
          { StringWrapper characterspec000 = ((StringWrapper)(characterspec));

            { char renamed_Char = Stella.NULL_CHARACTER;
              String vector000 = characterspec000.wrapperValue;
              int index000 = 0;
              int length000 = vector000.length();
              Cons collect000 = null;

              for (;index000 < length000; index000 = index000 + 1) {
                renamed_Char = vector000.charAt(index000);
                if (collect000 == null) {
                  {
                    collect000 = Cons.cons(CharacterWrapper.wrapCharacter(renamed_Char), Stella.NIL);
                    if (charset == Stella.NIL) {
                      charset = collect000;
                    }
                    else {
                      Cons.addConsToEndOfConsList(charset, collect000);
                    }
                  }
                }
                else {
                  {
                    collect000.rest = Cons.cons(CharacterWrapper.wrapCharacter(renamed_Char), Stella.NIL);
                    collect000 = collect000.rest;
                  }
                }
              }
            }
          }
        }
        else if (Surrogate.subtypeOfCharacterP(testValue000)) {
          { CharacterWrapper characterspec000 = ((CharacterWrapper)(characterspec));

            charset = Cons.cons(characterspec000, charset);
          }
        }
        else if (testValue000 == Stella.SGT_STELLA_CONS) {
          { Cons characterspec000 = ((Cons)(characterspec));

            { Stella_Object spec = null;
              Cons iter000 = characterspec000;

              for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
                spec = iter000.value;
                parsedspec = Stella_Object.parseTokenizerCharacterSpec(spec, Stella.NIL_LIST);
                if (parsedspec == null) {
                  return (null);
                }
                { CharacterWrapper renamed_Char = null;
                  Cons iter001 = parsedspec;
                  Cons collect001 = null;

                  for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
                    renamed_Char = ((CharacterWrapper)(iter001.value));
                    if (collect001 == null) {
                      {
                        collect001 = Cons.cons(renamed_Char, Stella.NIL);
                        if (charset == Stella.NIL) {
                          charset = collect001;
                        }
                        else {
                          Cons.addConsToEndOfConsList(charset, collect001);
                        }
                      }
                    }
                    else {
                      {
                        collect001.rest = Cons.cons(renamed_Char, Stella.NIL);
                        collect001 = collect001.rest;
                      }
                    }
                  }
                }
              }
            }
          }
        }
        else if (Surrogate.subtypeOfP(testValue000, Stella.SGT_STELLA_GENERALIZED_SYMBOL)) {
          { GeneralizedSymbol characterspec000 = ((GeneralizedSymbol)(characterspec));

            { String testValue001 = characterspec000.symbolName;

              if (Stella.stringEqlP(testValue001, "ANY")) {
                { int i = Stella.NULL_INTEGER;
                  int iter002 = 0;
                  int upperBound000 = Stella.$MAX_TOKENIZER_CHARACTERS$ - 1;
                  Cons collect002 = null;

                  for (;iter002 <= upperBound000; iter002 = iter002 + 1) {
                    i = iter002;
                    if (collect002 == null) {
                      {
                        collect002 = Cons.cons(CharacterWrapper.wrapCharacter((char) i), Stella.NIL);
                        if (charset == Stella.NIL) {
                          charset = collect002;
                        }
                        else {
                          Cons.addConsToEndOfConsList(charset, collect002);
                        }
                      }
                    }
                    else {
                      {
                        collect002.rest = Cons.cons(CharacterWrapper.wrapCharacter((char) i), Stella.NIL);
                        collect002 = collect002.rest;
                      }
                    }
                  }
                }
              }
              else if (Stella.stringEqlP(testValue001, "OTHERWISE")) {
                { Cons set = null;
                  Cons iter003 = allcharactersets.theConsList;

                  for (;!(iter003 == Stella.NIL); iter003 = iter003.rest) {
                    set = ((Cons)(iter003.value));
                    { CharacterWrapper renamed_Char = null;
                      Cons iter004 = set;
                      Cons collect003 = null;

                      for (;!(iter004 == Stella.NIL); iter004 = iter004.rest) {
                        renamed_Char = ((CharacterWrapper)(iter004.value));
                        if (collect003 == null) {
                          {
                            collect003 = Cons.cons(renamed_Char, Stella.NIL);
                            if (charset == Stella.NIL) {
                              charset = collect003;
                            }
                            else {
                              Cons.addConsToEndOfConsList(charset, collect003);
                            }
                          }
                        }
                        else {
                          {
                            collect003.rest = Cons.cons(renamed_Char, Stella.NIL);
                            collect003 = collect003.rest;
                          }
                        }
                      }
                    }
                  }
                }
                { int i = Stella.NULL_INTEGER;
                  int iter005 = 0;
                  int upperBound001 = Stella.$MAX_TOKENIZER_CHARACTERS$ - 1;
                  Cons collect004 = null;

                  for (;iter005 <= upperBound001; iter005 = iter005 + 1) {
                    i = iter005;
                    if (!charset.memberP(CharacterWrapper.wrapCharacter((char) i))) {
                      if (collect004 == null) {
                        {
                          collect004 = Cons.cons(CharacterWrapper.wrapCharacter((char) i), Stella.NIL);
                          if (complementset == Stella.NIL) {
                            complementset = collect004;
                          }
                          else {
                            Cons.addConsToEndOfConsList(complementset, collect004);
                          }
                        }
                      }
                      else {
                        {
                          collect004.rest = Cons.cons(CharacterWrapper.wrapCharacter((char) i), Stella.NIL);
                          collect004 = collect004.rest;
                        }
                      }
                    }
                  }
                }
                charset = complementset;
              }
              else {
                return (null);
              }
            }
          }
        }
        else {
          return (null);
        }
      }
      return (charset);
    }
  }