processUExtensions method

void processUExtensions()

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

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

Implementation

void processUExtensions() {
  if (_uExtensions != null) {
    problems.add('duplicate "u"');
    return;
  }
  _uExtensions = <String, String>{};
  var empty = true;
  final attributes = <String>[];
  while (acceptLowAlphaNumeric3to8()) {
    attributes.add(_accepted);
  }
  if (attributes.isNotEmpty) {
    empty = false;
    attributes.sort();
    _uExtensions![''] = attributes.join('-');
  }
  // unicode_locale_extensions: collect "(sep keyword)*".
  while (acceptUExtensionKey()) {
    empty = false;
    var key = _accepted;
    final typeParts = <String>[];
    while (acceptLowAlphaNumeric3to8()) {
      typeParts.add(_accepted);
    }
    if (!_uExtensions!.containsKey(key)) {
      if (typeParts.length == 1 && typeParts[0] == 'true') {
        _uExtensions![key] = '';
      } else {
        _uExtensions![key] = typeParts.join('-');
      }
    } else {
      problems.add('duplicate "$key"');
    }
  }
  if (empty) {
    problems.add('empty "u"');
  }
}