operator | method

CharMatcher operator |(
  1. CharMatcher other
)

Returns a matcher that matches any character matched by either this matcher or other.

Implementation

CharMatcher operator |(CharMatcher other) {
  if (other is AnyCharMatcher) {
    return other;
  } else if (other is NoneCharMatcher) {
    return this;
  } else if (other is DisjunctiveCharMatcher) {
    return DisjunctiveCharMatcher([this, ...other.matchers]);
  } else {
    return DisjunctiveCharMatcher([this, other]);
  }
}