scoop:scoop.regex:0.1.0
src/options.scoop
Selected production source · src/options.scoop
1
package scoop.regex3
/** Options applied when compiling a PCRE2 UTF-8 pattern. Inline pattern options remain effective. */4
public enum RegexOption : Equals<RegexOption>, Hash {5
/** Use PCRE2's Unicode case equivalences. */6
IgnoreCase,7
/** Let line anchors recognize internal newlines. */8
Multiline,9
/** Let a dot match newlines. */10
DotMatchesAll,11
/** Ignore unescaped pattern whitespace and permit comments. */12
Comments,13
/** Restrict character classes and their word boundaries to ASCII. */14
AsciiClasses,15
/** Permit multiple capture groups with the same name. */16
DuplicateNames18
internal val mask: UInt get() = when (this) {19
case IgnoreCase -> 1u20
case Multiline -> 2u21
case DotMatchesAll -> 4u22
case Comments -> 8u23
case AsciiClasses -> 16u24
case DuplicateNames -> 32u25
}27
/** Compares the option identities. */28
public override operator fun equals(other: RegexOption): Boolean = mask == other.mask29
/** Returns a hash consistent with option equality. */30
public override fun hash(): Long = mask.toLong()31
}