processTExtensions method

void processTExtensions()

Consumes tags matched by transformed_extensions in the specification, except that the 't' singleton must already be accepted.

If parsing fails, atEnd() will be false and/or problems will not be empty.

Implementation

void processTExtensions() {
  if (_tExtensions != null) {
    problems.add('duplicate "t"');
    return;
  }
  _tExtensions = <String, String>{};
  var empty = true;
  final tlang = <String>[];
  if (acceptLanguage()) {
    empty = false;
    tlang.add(replaceDeprecatedLanguageSubtag(_accepted));
    if (acceptScript()) {
      tlang.add(_accepted);
    }
    if (acceptRegion()) {
      tlang.add(replaceDeprecatedRegionSubtag(_accepted.toUpperCase())
          .toLowerCase());
    }
    acceptVariants();
    tlang.addAll(_acceptedList!);
    _tExtensions![''] = tlang.join('-');
  }
  // transformed_extensions: collect "(sep tfield)*".
  while (acceptTExtensionKey()) {
    var tkey = _accepted;
    final tvalueParts = <String>[];
    while (acceptLowAlphaNumeric3to8()) {
      tvalueParts.add(_accepted);
    }
    if (tvalueParts.isNotEmpty) {
      empty = false;
      if (!_tExtensions!.containsKey(tkey)) {
        _tExtensions![tkey] = tvalueParts.join('-');
      } else {
        problems.add('duplicate "$tkey"');
      }
    } else {
      problems.add('empty "$tkey"');
    }
  }
  if (empty) {
    problems.add('empty "t"');
  }
}