visitNotPredicate method

  1. @override
void visitNotPredicate(
  1. NotPredicateExpression node
)
override

Implementation

@override
void visitNotPredicate(NotPredicateExpression node) {
  final child = node.expression;
  child.accept(this);
  SparseBoolList? childCharacters;
  if (child is AnyCharacterExpression) {
    childCharacters = child.startCharacters;
  } else if (child is CharacterClassExpression) {
    childCharacters = child.startCharacters;
  } else if (child is LiteralExpression) {
    final text = child.text;
    if (text.length == 1) {
      final rune = text.runes.first;
      childCharacters = SparseBoolList();
      final group = GroupedRangeList(rune, rune, true);
      childCharacters.addGroup(group);
    }
  }

  if (childCharacters != null) {
    final startCharacters = SparseBoolList();
    for (final group in Expression.allCharactersWithEof.groups) {
      startCharacters.addGroup(group);
    }

    for (final range in childCharacters.groups) {
      final group = GroupedRangeList(range.start, range.end, false);
      startCharacters.setGroup(group);
    }

    _addCharacters(node, startCharacters);
  } else {
    _addAllCharactersWithEof(node);
  }
}