isEqualTo method

  1. @nonVirtual
bool isEqualTo(
  1. Parser other, [
  2. Set<Parser>? seen
])

Tests if this parser is structurally equal to other.

Automatically deals with recursive parsers and parsers that refer to other parsers. Do not override this method; instead customize hasEqualProperties and children.

Implementation

@nonVirtual
bool isEqualTo(Parser other, [Set<Parser>? seen]) {
  if (this == other) {
    return true;
  }
  if (runtimeType != other.runtimeType || !hasEqualProperties(other)) {
    return false;
  }
  seen ??= {};
  return !seen.add(this) || hasEqualChildren(other, seen);
}