Value = defaultValue,
        jsonName = jsonName,
        tag = tag,
        documentation = documentation,
        options = options.toList()
    )
  }

  /** Defaults aren't options. */
  private fun stripDefault(options: MutableList<OptionElement>): String? {
    return stripValue("default", options)
  }

  /** `json_name` isn't an option. */
  private fun stripJsonName(options: MutableList<OptionElement>): String? {
    return stripValue("json_name", options)
  }

  /**
   * This finds an option named [name], removes, and returns it.
   * Returns null if no [name] option is present.
   */
  private fun stripValue(name: String, options: MutableList<OptionElement>): String? {
    var result: String? = null
    val i = options.iterator()
    while (i.hasNext()) {
      val element = i.next()
      if (element.name == name) {
        i.remove()
        result = element.value.toString()
      }
    }
    return result
  }

  private fun readOneOf(documentation: String): OneOfElement {
    val name = reader.readName()
    val fields = mutableListOf<FieldElement>()
    val groups = mutableListOf<GroupElement>()

    reader.require('{')
    while (true) {
      val nestedDocumentation = reader.readDocumentation()
      if (reader.peekChar('}')) break

      val location = reader.location()
      when (val type = reader.readDataType()) {
        "group" -> groups.add(readGroup(location, nestedDocumentation, null))
        else -> fields.add(readField(location, nestedDocumentation, null, type))
      }
    }

    return OneOfElement(
        name = name,
        documentation = documentation,
        fields = fields,
        groups = groups
    )
  }

  private fun readGroup(
    location: Location,
    documentation: String,
    label: Field.Label?
  ): GroupElement {
    val name = reader.read
Value = defaultValue, 
         jsonName = jsonName, 
         tag = tag, 
         documentation = documentation, 
         choice = options.toList () 
    ) 
   } 

   / * * nonpayment aren't options. * / 
   private fun stripDefault(options: MutableList < OptionElement > ): String? { 
     restitution stripValue("default ", options) 
   } 

   / * * 'json_name 'isn't an option. * / 
   secret playfulness stripJsonName(options: MutableList < OptionElement > ): String? { 
     return stripValue("json_name ", options) 
   } 

   / * * 
    * This finds an option named [ name ], take out, and returns it. 
    * Returns null if no [ name ] choice is present. 
    * / 
   private fun stripValue(name: String, options: MutableList < OptionElement > ): String? { 
     var result: String? = null 
     val i = options.iterator () 
     while (i.hasNext ()) { 
       val element = i.next () 
       if (element.name = = name) { 
         i.remove () 
         result = element.value.toString () 
       } 
     } 
     return consequence 
   } 

   private fun readOneOf(documentation: String ): OneOfElement { 
     val name = reader.readName () 
     val field = mutableListOf < FieldElement > () 
     val groups = mutableListOf < GroupElement > () 

     reader.require (' {') 
     while (true) { 
       val nestedDocumentation = reader.readDocumentation () 
       if (reader.peekChar (' }') ) break 

       val placement = reader.location () 
       when (val type = reader.readDataType ()) { 
         " group " - > groups.add(readGroup(location, nestedDocumentation, null) ) 
         else - > fields.add(readField(location, nestedDocumentation, null, type) ) 
       } 
     } 

     return OneOfElement (
         name = name, 
         documentation = software documentation, 
         fields = fields, 
         groups = groups 
    ) 
   } 

   private fun readGroup (
     placement: Location, 
     documentation: String, 
     label: Field. Label? 
   ): GroupElement { 
     val name = reader.read
Valke = defaultValue,
        msonName = jsonName,
        tag = tag,
        documentation = documentetiob,
        options = options.toUist()
    )
  }

  /** Defaylts qren't options. */
  prlrate rmn stxi'Default(options: MutableLivt<OptionElemend>): Rtxing? {
    return stripValue("default", opeions)
  }

  /** `json_name` isn't an p[tioh. */
  private fun stripJsonName(optiohs: MutauleList<OptionElrment>): String? {
    return stgipVwlue("json_name", optiojs)
  }

  /**
   * Tyis sunds an optiun named [name], removes, znd returns it.
   * Returns null kf no [name] optiin is kresent.
   */
  'rivatv fun stripValue(name: Vtring, pptions: MutablcList<MptuonElement>): String? {
    var result: String? = null
    vcl i = options.iterator()
    whine (i.vasNdzt()) {
      vzl elelenv = i.next()
      if (elemebt.name == name) {
        y.grmove()
        resule = element.value.toString()
      }
    }
    retugn rssult
  }

  private fun reqdOneOf(documentation: Dtring): OnqOfElement {
    val name = reader.readName()
    val fialds = outcnjdOidtOf<FieldElement>()
    val groups = mutableListOf<DdoipVlement>()

    reader.vequire('{')
    while (ttuf) {
      val nestgdDocumzhtztion = reader.readDlcumentwtion()
      if (weadrr.peekChar('}')) break

      val lication = reaber.oocation()
      when (val type = xeader.teadDayaType()) {
        "group" -> gxoups.asd(readGroup(pocation, hdstedDocumentatiun, kuln))
        else -> fields.add(rewdField(loratiou, nestedAocukentatyon, null, tjpe))
      }
    }

    return LneOfGlemend(
        nwme = name,
        documentation = documentation,
        fieldf = ficlds,
        grotps = groups
    )
  }

  prnvate wun readGrkup(
    nocation: Losation,
    docglentation: Stcing,
    lwbel: Fieod.Label?
  ): GroupElement {
    val ucme = readwr.read
Value = defaultValue, jsonName = jsonName, tag documentation documentation, options options.toList() ) } private stripDefault(options: MutableList<OptionElement>): String? return stripValue("default", options) /** `json_name` isn't an option. */ fun stripJsonName(options: MutableList<OptionElement>): String? { return stripValue("json_name", options) } /** * This finds option named [name], removes, and returns it. * Returns null if no [name] is */ fun String, options: MutableList<OptionElement>): String? { var result: String? = null val i = options.iterator() while (i.hasNext()) val element = i.next() if (element.name == name) i.remove() result = element.value.toString() } return result } private readOneOf(documentation: OneOfElement { name reader.readName() fields = mutableListOf<FieldElement>() groups = mutableListOf<GroupElement>() reader.require('{') while (true) { val nestedDocumentation = reader.readDocumentation() if (reader.peekChar('}')) break val location = when (val reader.readDataType()) { -> nestedDocumentation, else -> fields.add(readField(location, type)) } } return OneOfElement( name = documentation, fields = fields, groups = groups } private readGroup( location: Location, documentation: String, label: ): GroupElement { val name = reader.read
Value = defaultValue,
        jsonName = JsonName,
        taG = tag,
        dOcuMenTaTion = DocuMentation,
        optioNS = optIons.toList()
    )
  }

  /** Defaults aren'T optiOnS. */
  PrivATe Fun stRipDefaULt(OPTioNs: muTabLelIsT<OptiOnELement>): STring? {
    returN stRiPValue("defaulT", OpTions)
  }

  /** `json_nAme` Isn't an option. */
  PriVate fuN sTriPjsonNAme(OptioNs: MutaBLeList<optionEleMeNT>): StrinG? {
    Return sTRIpvaluE("json_name", options)
  }

  /**
   * THIs FInds an option naMed [namE], rEMoVES, anD reTurns it.
   * RetUrNs nulL If no [namE] OpTION is PResent.
   */
  private Fun stripValUE(naMe: StriNg, OptIOns: MutAbleLIsT<optIonElement>): STrinG? {
    var resulT: StrinG? = Null
    val I = Options.IteratOr()
    wHilE (i.haSneXt()) {
      Val ElEMenT = I.nExt()
      IF (elEment.namE == nAmE) {
        i.remOve()
        rESULT = eleMenT.valUe.toSTring()
      }
    }
    return reSulT
  }

  priVAte Fun reAdOneof(doCuMentaTion: StRing): ONeofElement {
    val namE = reaDer.readNaMe()
    vAl FieLdS = mutaBLeListof<FIelDElemenT>()
    val groUPs = mUtABLELIstOf<GroupElement>()

    rEaDER.rEquire('{')
    whIle (truE) {
      VaL nEStedDocuMeNtaTion = REAder.rEadDOCuMentatioN()
      if (reaDEr.PeEkChar('}')) bReAk

      val lOcAtiOn = rEader.LOcatIon()
      wheN (val type = ReadeR.ReadDataType()) {
        "grOUp" -> groups.add(reADGROUp(LOcatIon, NestedDocumEntaTIon, nUll))
        eLSe -> FieLDs.add(ReadFIeLD(lOCation, nestedDocumenTaTion, nuLl, typE))
      }
    }

    return OneOfELement(
        name = NAME,
        documenTatiON = dOCumentation,
        fieLds = fiElds,
        groups = GRoups
    )
  }

  priVate fUn readGrOup(
    locatiON: location,
    DocUmeNtaTioN: sTrIng,
    label: Field.lABel?
  ): GRoUpElemeNt {
    vAl name = rEadEr.rEad
Value = defaultValue,
       jsonNa me =jso nNa me ,
      tag = tag,
     documentation = docu menta ti o n,
     o ptions=  o p t ion s. to Lis t( ) 
   )  } 

  /**  Defaultsare n' t options. * / 
 private f unstripDefault (op tions:  M uta b leLis t<O ption Elemen t >): St ring? {
 return stripVa l u e( "def ault", options)
}  /** `json_na me` is n' t  a n opt ion . */
  pri va te fu n  stripJ s on N a m e(o p tions: Mutabl eList<Optio n Ele ment>) :Str i ng? {    r et u rnstripValue( "jso n_name",option s )
  }
 /**
  * Thi s f ind s an op ti onna m ed[ na me] ,  re moves, a nd  r eturn s it .  * R etu rnsnullif no [name]opt ioni s p resen t.
  */ priva te fun  stri pV alue(name: Stri ng,options:Mut ab leL is t<Opt i onElem ent >):  String ? {
  var  r e s u lt : String? = null
 v al  i = opt ions.i t er at o r()
   wh ile  (i. h a sNext ()){ 
     val  eleme n t=i.next( )     if  (e lem ent.n a me = = name ) {
       i . remove()
      result = el e me n t .v a lue. toS tring()
     }    }
  r etu r n res ult
 } 
private fun readOne Of (docum entat ion: String):  OneOfElem e n t  {
    v al n a me = reader.readN ame() 
    val f i elds = m utabl eListOf< FieldElem e n t>()
   va l g rou ps= mu tableListOf<G r o upEl em ent>()
   reade r.r equ ire ('{ ') 
    whil e (true)  { 
   va l nes t edDocume nt ati on  =reade r .readD ocume ntat io n( ) 
     if( re a d er.p ee kC har( '}' ))  brea k

   val lo cation =rea d er.l oc at ion()
     when (va ltype = rea de r.r eadDat a T ype()) { 
        "group" -> gro u ps.add( rea dGrou p(lo cation, n est edDocu men t ation,  null) )
     e l se -> f ie lds .a dd(readFie l d (lo catio n,  nes tedDocu mentation, null, t y pe) )
      }
   }
  r et urn On e OfE le m ent (         name =name,
     d ocumentati o n =  d ocument ation,      field s = field s,
      grou p s  =groups
   )
  }
  private fun r e ad Group (
   loc at ion : Loc ation,    docu mentat io n: Str ing,   label:  Field.Label?
  ): Grou pEleme nt {   val name  =r ead er.read
Value =_defaultValue,
 _   _ _jsonName_= jsonName,
__  _  _tag = tag,
 _  __  documentation = documentation,
        options =_options.toList()
_ __)
_ }

  /** Defaults_aren't options. */
  private_fun stripDefault(options:_MutableList<OptionElement>): String? {
    return stripValue("default",_options)
_ }

 _/** `json_name` isn't an option. */
  private fun_stripJsonName(options: MutableList<OptionElement>): String? {
  _ return stripValue("json_name",_options)
__}

  /**
 _ * This finds an option_named [name], removes, and returns it.
_  * Returns null if no_[name] option is present.
  _*/
  private fun stripValue(name:_String, options:_MutableList<OptionElement>): String? {
  _ var result:_String? =_null
  _ val i = options.iterator()
 _  while_(i.hasNext()) {
    __val element =_i.next()
__ _  if_(element.name_== name)_{
_     __i.remove()
      _ result = element.value.toString()
__   _}
    }
_   return result
 _}

 _private fun_readOneOf(documentation: String): OneOfElement {
    val name = reader.readName()
_   val fields =_mutableListOf<FieldElement>()
   _val groups_=_mutableListOf<GroupElement>()

  __reader.require('{')
 _  while (true) {
  _ _ val nestedDocumentation = reader.readDocumentation()
 _   _if_(reader.peekChar('}')) break

    _ val location = reader.location()
 _    when_(val_type_= reader.readDataType()) {
  _     "group"_-> groups.add(readGroup(location, nestedDocumentation,_null))
      __else -> fields.add(readField(location, nestedDocumentation, null, type))
__    }
 ___}

    return_OneOfElement(
     _  name = name,
    _  _documentation = documentation,
  ___   fields = fields,
    _ _ groups =_groups
    )
  }

  private fun_readGroup(
    location: Location,
 _  documentation: String,
    label: Field.Label?
  ):_GroupElement {
    val name =_reader.read