moonbit-community/treesitter/regex_syntax/hir does not have a README file

    Interval

    pub(open) trait Interval : Eq + Compare {
    fn lower(Self) -> Int
    fn upper(Self) -> Int
    fn create(Int, Int) -> Self
    fn case_fold_simple(Self, Array[Self]) -> Unit raise CaseFoldError
    fn bound_min_value() -> Int
    fn bound_max_value() -> Int
    fn bound_increment(Int) -> Int
    fn bound_decrement(Int) -> Int
    }

    An inclusive interval with bounds of type Int (upstream Interval, with Interval::Bound fixed to code points / byte values).

    CaseFoldError

    pub(all) suberror CaseFoldError {
    CaseFoldError
    } derive(
    Debug
    )

    An error that occurs when Unicode-aware simple case folding fails.

    This error can occur when the case mapping tables necessary for Unicode aware case folding are unavailable. This only occurs when the unicode-case feature is disabled, so it never happens here.

    HirError

    pub(all) suberror HirError {
    HirError(kind~ : ErrorKind, pattern~ : String, span~ :
    Span
    )
    } derive(Eq,
    Debug
    )

    An error that can occur while translating an Ast to a Hir (upstream hir::Error).

    HirError::kind

    fn HirError::kind(self : HirError) -> ErrorKind

    Return the type of this error.

    HirError::pattern

    fn HirError::pattern(self : HirError) -> String

    The original pattern string in which this error occurred.

    HirError::span

    Return the span at which this error occurred.

    UnicodeError

    pub(all) suberror UnicodeError {
    PropertyNotFound
    PropertyValueNotFound
    PerlClassNotFound
    } derive(
    Debug
    )

    An error that occurs when dealing with Unicode (upstream unicode::Error).

    Utf8Error

    pub(all) suberror Utf8Error {
    Utf8Error(valid_up_to~ : Int, error_len~ : Int?)
    } derive(Eq,
    Debug
    )

    Rust core::str::Utf8Error.
    impl Show for Utf8Error

    Capture

    pub(all) struct Capture {
    index : UInt
    name : String?
    sub : Hir
    } derive(Eq,
    Debug
    )

    The high-level intermediate representation for a capturing group.

    Class

    pub(all) enum Class {
    Unicode(ClassUnicode)
    Bytes(ClassBytes)
    } derive(Eq,
    Debug
    )

    The high-level intermediate representation of a character class.

    Class::case_fold_simple

    fn Class::case_fold_simple(self : Class) -> Unit

    Apply Unicode simple case folding to this character class, in place.

    Class::is_empty

    fn Class::is_empty(self : Class) -> Bool

    Returns true if and only if this character class is empty. That is, it has no elements.

    Class::is_utf8

    fn Class::is_utf8(self : Class) -> Bool

    Returns true if and only if this character class will only ever match valid UTF-8.

    Class::literal

    fn Class::literal(self : Class) -> Bytes?

    If this class consists of exactly one element (whether a codepoint or a byte), then return it as a literal byte string.

    Class::maximum_len

    fn Class::maximum_len(self : Class) -> UInt64?

    Returns the length, in bytes, of the longest string matched by this character class.

    Class::minimum_len

    fn Class::minimum_len(self : Class) -> UInt64?

    Returns the length, in bytes, of the smallest string matched by this character class.

    Class::negate

    fn Class::negate(self : Class) -> Unit

    Negate this character class in place.

    Class::try_case_fold_simple

    fn Class::try_case_fold_simple(self : Class) -> Unit raise CaseFoldError

    Apply Unicode simple case folding to this character class, in place.

    ClassBytes

    pub struct ClassBytes {
    // private fields
    } derive(Eq,
    Debug
    )

    A set of characters represented by arbitrary bytes.

    Each byte corresponds to one character.

    ClassBytes::case_fold_simple

    fn ClassBytes::case_fold_simple(self : ClassBytes) -> Unit

    Expand this character class such that it contains all case folded characters. For example, if this class consists of the range a-z, then applying case folding will result in the class containing both the ranges a-z and A-Z.

    Note that this only applies ASCII case folding, which is limited to the characters a-z and A-Z.

    ClassBytes::copy

    fn ClassBytes::copy(self : ClassBytes) -> ClassBytes

    A copy of this class (Rust Clone).

    ClassBytes::difference

    fn ClassBytes::difference(self : ClassBytes, other : ClassBytes) -> Unit

    Subtract the given byte class from this byte class, in place.

    ClassBytes::empty

    fn ClassBytes::empty() -> ClassBytes

    Create a new class with no ranges.

    ClassBytes::intersect

    fn ClassBytes::intersect(self : ClassBytes, other : ClassBytes) -> Unit

    Intersect this byte class with the given byte class, in place.

    ClassBytes::is_ascii

    fn ClassBytes::is_ascii(self : ClassBytes) -> Bool

    Returns true if and only if this character class will either match nothing or only ASCII bytes. Stated differently, this returns false if and only if this class contains a non-ASCII byte.

    ClassBytes::iter

    Return an iterator over all ranges in this class.

    ClassBytes::literal

    fn ClassBytes::literal(self : ClassBytes) -> Bytes?

    If this class consists of exactly one byte, then return it as a literal byte string.

    ClassBytes::maximum_len

    fn ClassBytes::maximum_len(self : ClassBytes) -> UInt64?

    Returns the length, in bytes, of the longest string matched by this character class.

    ClassBytes::minimum_len

    fn ClassBytes::minimum_len(self : ClassBytes) -> UInt64?

    Returns the length, in bytes, of the smallest string matched by this character class.

    ClassBytes::negate

    fn ClassBytes::negate(self : ClassBytes) -> Unit

    Negate this byte class.

    ClassBytes::new

    Create a new class from a sequence of ranges.

    ClassBytes::push

    fn ClassBytes::push(self : ClassBytes, range : ClassBytesRange) -> Unit

    Add a new range to this set.

    ClassBytes::ranges

    Return the underlying ranges as a slice.

    ClassBytes::symmetric_difference

    fn ClassBytes::symmetric_difference(self : ClassBytes, other : ClassBytes) -> Unit

    Compute the symmetric difference of the given byte classes, in place.

    ClassBytes::to_unicode_class

    fn ClassBytes::to_unicode_class(self : ClassBytes) -> ClassUnicode?

    If this class consists of only ASCII ranges, then return its corresponding and equivalent Unicode class.

    ClassBytes::union

    fn ClassBytes::union(self : ClassBytes, other : ClassBytes) -> Unit

    Union this byte class with the given byte class, in place.

    ClassBytesRange

    pub(all) struct ClassBytesRange {
    start : Byte
    end : Byte
    } derive(Compare, Eq,
    Debug
    )

    A single range of characters represented by arbitrary bytes.

    The range is closed. That is, the start and end of the range are included in the range.

    ClassBytesRange::end

    fn ClassBytesRange::end(self : ClassBytesRange) -> Byte

    Return the end of this range.

    ClassBytesRange::len

    fn ClassBytesRange::len(self : ClassBytesRange) -> Int

    Returns the number of bytes in this range.

    ClassBytesRange::new

    fn ClassBytesRange::new(start : Byte, end : Byte) -> ClassBytesRange

    Create a new byte range for a character class.

    The returned range is always in a canonical form. That is, the range returned always satisfies the invariant that start <= end.

    ClassBytesRange::start

    fn ClassBytesRange::start(self : ClassBytesRange) -> Byte

    Return the start of this range.

    ClassQuery

    pub(all) enum ClassQuery {
    OneLetter(Char)
    Binary(String)
    ByValue(property_name~ : String, property_value~ : String)
    } derive(
    Debug
    )

    A query for finding a character class defined by Unicode. This supports either use of a property name directly, or lookup by property value. The former generally refers to Binary properties (see UTS#44, Table 8), but as a special exception (see UTS#18, Section 1.2) both general categories (an enumeration) and scripts (a catalog) are supported as if each of their possible values were a binary property.

    In all circumstances, property names and values are normalized and canonicalized. That is, GC == gc == GeneralCategory == general_category.

    ClassUnicode

    pub struct ClassUnicode {
    // private fields
    } derive(Eq,
    Debug
    )

    A set of characters represented by Unicode scalar values.

    ClassUnicode::case_fold_simple

    fn ClassUnicode::case_fold_simple(self : ClassUnicode) -> Unit

    Expand this character class such that it contains all case folded characters, according to Unicode's "simple" mapping.

    ClassUnicode::copy

    A copy of this class (Rust Clone).

    ClassUnicode::difference

    fn ClassUnicode::difference(self : ClassUnicode, other : ClassUnicode) -> Unit

    Subtract the given character class from this character class, in place.

    ClassUnicode::empty

    fn ClassUnicode::empty() -> ClassUnicode

    Create a new class with no ranges.

    ClassUnicode::intersect

    fn ClassUnicode::intersect(self : ClassUnicode, other : ClassUnicode) -> Unit

    Intersect this character class with the given character class, in place.

    ClassUnicode::is_ascii

    fn ClassUnicode::is_ascii(self : ClassUnicode) -> Bool

    Returns true if and only if this character class will either match nothing or only ASCII bytes. Stated differently, this returns false if and only if this class contains a non-ASCII codepoint.

    ClassUnicode::iter

    Return an iterator over all ranges in this class.

    ClassUnicode::literal

    fn ClassUnicode::literal(self : ClassUnicode) -> Bytes?

    If this class consists of exactly one codepoint, then return its corresponding UTF-8 encoding. Otherwise, return None.

    ClassUnicode::maximum_len

    fn ClassUnicode::maximum_len(self : ClassUnicode) -> UInt64?

    Returns the length, in bytes, of the longest string matched by this character class.

    ClassUnicode::minimum_len

    fn ClassUnicode::minimum_len(self : ClassUnicode) -> UInt64?

    Returns the length, in bytes, of the smallest string matched by this character class.

    ClassUnicode::negate

    fn ClassUnicode::negate(self : ClassUnicode) -> Unit

    Negate this character class.

    ClassUnicode::new

    Create a new class from a sequence of ranges.

    The given ranges do not need to be in any specific order, and ranges may overlap. Ranges will automatically be sorted into a canonical non-overlapping order.

    ClassUnicode::push

    fn ClassUnicode::push(self : ClassUnicode, range : ClassUnicodeRange) -> Unit

    Add a new range to this set.

    ClassUnicode::ranges

    Return the underlying ranges as a slice.

    ClassUnicode::symmetric_difference

    fn ClassUnicode::symmetric_difference(self : ClassUnicode, other : ClassUnicode) -> Unit

    Compute the symmetric difference of the given character classes, in place.

    ClassUnicode::to_byte_class

    fn ClassUnicode::to_byte_class(self : ClassUnicode) -> ClassBytes?

    If this class consists of only ASCII ranges, then return its corresponding and equivalent byte class.

    ClassUnicode::try_case_fold_simple

    fn ClassUnicode::try_case_fold_simple(self : ClassUnicode) -> Unit raise CaseFoldError

    Expand this character class such that it contains all case folded characters, according to Unicode's "simple" mapping.

    ClassUnicode::union

    fn ClassUnicode::union(self : ClassUnicode, other : ClassUnicode) -> Unit

    Union this character class with the given character class, in place.

    ClassUnicodeRange

    pub(all) struct ClassUnicodeRange {
    start : Int
    end : Int
    } derive(Compare, Eq,
    Debug
    )

    A single range of characters represented by Unicode scalar values.

    The range is closed. That is, the start and end of the range are included in the range.

    ClassUnicodeRange::end

    fn ClassUnicodeRange::end(self : ClassUnicodeRange) -> Int

    Return the end of this range.

    ClassUnicodeRange::len

    fn ClassUnicodeRange::len(self : ClassUnicodeRange) -> Int

    Returns the number of codepoints in this range.

    ClassUnicodeRange::new

    fn ClassUnicodeRange::new(start : Int, end : Int) -> ClassUnicodeRange

    Create a new Unicode scalar value range for a character class.

    The returned range is always in a canonical form. That is, the range returned always satisfies the invariant that start <= end.

    ClassUnicodeRange::start

    fn ClassUnicodeRange::start(self : ClassUnicodeRange) -> Int

    Return the start of this range.

    Dot

    pub(all) enum Dot {
    AnyChar
    AnyByte
    AnyCharExcept(Int)
    AnyCharExceptLF
    AnyCharExceptCRLF
    AnyByteExcept(Byte)
    AnyByteExceptLF
    AnyByteExceptCRLF
    } derive(Eq,
    Debug
    )

    A type describing the different flavors of ..

    ErrorKind

    pub(all) enum ErrorKind {
    UnicodeNotAllowed
    InvalidUtf8
    InvalidLineTerminator
    UnicodePropertyNotFound
    UnicodePropertyValueNotFound
    UnicodePerlClassNotFound
    UnicodeCaseUnavailable
    } derive(Eq,
    Debug
    )

    The type of an error that occurred while building an Hir.
    impl Show for ErrorKind

    Hir

    pub struct Hir {
    // private fields
    } derive(Eq,
    Debug
    )

    A high-level intermediate representation (HIR) for a regular expression.

    An HIR value is a combination of a [HirKind] and a set of [Properties]. An HirKind indicates what kind of regular expression it is (a literal, a repetition, a look-around assertion, etc.), where as a Properties describes various facts about the regular expression.

    Hir::alternation

    fn Hir::alternation(subs : Array[Hir]) -> Hir

    Returns the alternation of the given expressions.

    This flattens and simplifies the alternation as appropriate. This may include factoring out common prefixes or even rewriting the alternation as a character class.

    Note that an empty alternation is equivalent to Hir::fail(). (It is not possible for one to write an empty alternation, or even an alternation with a single sub-expression, in the concrete syntax of a regex.)

    Hir::capture

    fn Hir::capture(capture : Capture) -> Hir

    Creates a capture HIR expression.

    Note that there is no explicit HIR value for a non-capturing group. Since a non-capturing group only exists to override precedence in the concrete syntax and since an HIR already does its own grouping based on what is parsed, there is no need to explicitly represent non-capturing groups in the HIR.

    Hir::class

    fn Hir::class(class : Class) -> Hir

    Creates a class HIR expression. The class may either be defined over ranges of Unicode codepoints or ranges of raw byte values.

    Note that an empty class is permitted. An empty class is equivalent to Hir::fail().

    Hir::concat

    fn Hir::concat(subs : Array[Hir]) -> Hir

    Returns the concatenation of the given expressions.

    This attempts to flatten and simplify the concatenation as appropriate.

    Hir::dot

    fn Hir::dot(dot : Dot) -> Hir

    Returns an HIR expression for ..

    Hir::empty

    fn Hir::empty() -> Hir

    Returns an empty HIR expression.

    An empty HIR expression always matches, including the empty string.

    Hir::fail

    fn Hir::fail() -> Hir

    Returns an HIR expression that can never match anything. That is, the size of the set of strings in the language described by the HIR returned is 0.

    Hir::into_kind

    fn Hir::into_kind(self : Hir) -> HirKind

    Consumes ownership of this HIR expression and returns its underlying HirKind.

    Hir::kind

    fn Hir::kind(self : Hir) -> HirKind

    Returns a reference to the underlying HIR kind.

    Hir::literal

    fn Hir::literal(lit : Bytes) -> Hir

    Creates a literal HIR expression.

    This accepts anything that can be converted into a Box<[u8]>.

    Note that there is no mechanism for storing a char or a Box<str> in an HIR. Everything is "just bytes." Whether a Literal (or any HIR node) matches valid UTF-8 exclusively can be queried via [Properties::is_utf8].

    Hir::look

    fn Hir::look(look : Look) -> Hir

    Creates a look-around assertion HIR expression.

    Hir::properties

    fn Hir::properties(self : Hir) -> Properties

    Returns the properties computed for this Hir.

    Hir::repetition

    fn Hir::repetition(rep : Repetition) -> Hir

    Creates a repetition HIR expression.

    HirKind

    pub(all) enum HirKind {
    Empty
    Literal(Literal)
    Class(Class)
    Look(Look)
    Repetition(Repetition)
    Capture(Capture)
    Concat(Array[Hir])
    Alternation(Array[Hir])
    } derive(Eq,
    Debug
    )

    The underlying kind of an arbitrary [Hir] expression.

    HirKind::subs

    fn HirKind::subs(self : HirKind) -> Array[Hir]

    Returns a slice of this kind's sub-expressions, if any.

    IntervalSet

    pub struct IntervalSet[I] {
    // private fields
    }

    impl Eq for IntervalSet[I]

    IntervalSet::case_fold_simple

    fn[I : Interval + Eq + Compare] IntervalSet::case_fold_simple(self : IntervalSet[I]) -> Unit raise CaseFoldError

    Expand this interval set such that it contains all case folded characters. For example, if this class consists of the range a-z, then applying case folding will result in the class containing both the ranges a-z and A-Z.

    This returns an error if the necessary case mapping data is not available.

    IntervalSet::copy

    fn[I] IntervalSet::copy(self : IntervalSet[I]) -> IntervalSet[I]

    A copy of this set (Rust Clone).

    IntervalSet::difference

    fn[I : Interval + Eq + Compare] IntervalSet::difference(self : IntervalSet[I], other : IntervalSet[I]) -> Unit

    Subtract the given set from this set, in place.

    IntervalSet::intersect

    fn[I : Interval + Eq + Compare] IntervalSet::intersect(self : IntervalSet[I], other : IntervalSet[I]) -> Unit

    Intersect this set with the given set, in place.

    IntervalSet::intervals

    fn[I] IntervalSet::intervals(self : IntervalSet[I]) -> ArrayView[I]

    Return an immutable slice of intervals in this set.

    The sequence returned is in canonical ordering.

    IntervalSet::iter

    fn[I] IntervalSet::iter(self : IntervalSet[I]) -> Iter[I]

    Return an iterator over all intervals in this set.

    The iterator yields intervals in ascending order.

    IntervalSet::negate

    fn[I : Interval + Eq + Compare] IntervalSet::negate(self : IntervalSet[I]) -> Unit

    Negate this interval set.

    For all x where x is any element, if x was in this set, then it will not be in this set after negation.

    IntervalSet::new

    fn[I : Interval + Eq + Compare] IntervalSet::new(intervals : Array[I]) -> IntervalSet[I]

    Create a new set from a sequence of intervals. Each interval is specified as a pair of bounds, where both bounds are inclusive.

    The given ranges do not need to be in any specific order, and ranges may overlap.

    IntervalSet::push

    fn[I : Interval + Eq + Compare] IntervalSet::push(self : IntervalSet[I], interval : I) -> Unit

    Add a new interval to this set.

    IntervalSet::symmetric_difference

    fn[I : Interval + Eq + Compare] IntervalSet::symmetric_difference(self : IntervalSet[I], other : IntervalSet[I]) -> Unit

    Compute the symmetric difference of the two sets, in place.

    This computes the symmetric difference of two interval sets. This removes all elements in this set that are also in the given set, but also adds all elements from the given set that aren't in this set. That is, the set will contain all elements in either set, but will not contain any elements that are in both sets.

    IntervalSet::union

    fn[I : Interval + Eq + Compare] IntervalSet::union(self : IntervalSet[I], other : IntervalSet[I]) -> Unit

    Union this set with the given set, in place.

    Literal

    pub(all) struct Literal(Bytes) derive(Eq,
    Debug
    )

    The high-level intermediate representation of a literal.

    Look

    pub(all) enum Look {
    Start
    End
    StartLF
    EndLF
    StartCRLF
    EndCRLF
    WordAscii
    WordAsciiNegate
    WordUnicode
    WordUnicodeNegate
    WordStartAscii
    WordEndAscii
    WordStartUnicode
    WordEndUnicode
    WordStartHalfAscii
    WordEndHalfAscii
    WordStartHalfUnicode
    WordEndHalfUnicode
    } derive(Eq,
    Debug
    )

    The high-level intermediate representation for a look-around assertion.

    An assertion match is always zero-length. Also called an "empty match."

    Look::as_char

    fn Look::as_char(self : Look) -> Char

    Returns a convenient single codepoint representation of this look-around assertion.

    Look::as_repr

    fn Look::as_repr(self : Look) -> UInt

    Return the underlying representation of this look-around enumeration as an integer. Giving the return value to the [Look::from_repr] constructor is guaranteed to return the same look-around variant that one started with within a semver compatible release of this crate.

    Look::from_repr

    fn Look::from_repr(repr : UInt) -> Look?

    Given the underlying representation of a Look value, return the corresponding Look value if the representation is valid. Otherwise None is returned.

    Look::reversed

    fn Look::reversed(self : Look) -> Look

    Flip the look-around assertion to its equivalent for reverse searches.

    LookSet

    pub(all) struct LookSet {
    bits : UInt
    } derive(Eq,
    Debug
    )

    A set of look-around assertions.

    This is useful for efficiently tracking look-around assertions. For example, an [Hir] provides properties that return LookSets.

    LookSet::contains

    fn LookSet::contains(self : LookSet, look : Look) -> Bool

    Returns true if and only if the given look-around assertion is in this set.

    LookSet::empty

    fn LookSet::empty() -> LookSet

    Create an empty set of look-around assertions.

    LookSet::full

    fn LookSet::full() -> LookSet

    Create a full set of look-around assertions.

    LookSet::insert

    fn LookSet::insert(self : LookSet, look : Look) -> LookSet

    Return a new set that is equivalent to the original, but with the given assertion added to it. If the assertion is already in the set, then the returned set is equivalent to the original.

    LookSet::intersect

    fn LookSet::intersect(self : LookSet, other : LookSet) -> LookSet

    Returns a new set that is the intersection of this and the one given.

    LookSet::is_empty

    fn LookSet::is_empty(self : LookSet) -> Bool

    Returns true if and only if this set is empty.

    LookSet::len

    fn LookSet::len(self : LookSet) -> Int

    Returns the total number of look-around assertions in this set.

    LookSet::remove

    fn LookSet::remove(self : LookSet, look : Look) -> LookSet

    Return a new set that is equivalent to the original, but with the given assertion removed from it. If the assertion is not in the set, then the returned set is equivalent to the original.

    LookSet::singleton

    fn LookSet::singleton(look : Look) -> LookSet

    Create a look-around set containing the look-around assertion given.

    LookSet::subtract

    fn LookSet::subtract(self : LookSet, other : LookSet) -> LookSet

    Returns a new set that is the result of subtracting the given set from this set.

    LookSet::union

    fn LookSet::union(self : LookSet, other : LookSet) -> LookSet

    Returns a new set that is the union of this and the one given.

    Properties

    pub struct Properties {
    // private fields
    } derive(Eq,
    Debug
    )

    A type that collects various properties of an HIR value.

    Properties are always scalar values and represent meta data that is computed inductively on an HIR value. Properties are defined for all HIR values.

    Properties::explicit_captures_len

    fn Properties::explicit_captures_len(self : Properties) -> UInt64

    Returns the total number of explicit capturing groups in the corresponding HIR.

    Properties::is_alternation_literal

    fn Properties::is_alternation_literal(self : Properties) -> Bool

    Return true if and only if this HIR is either a simple literal or an alternation of simple literals.

    Properties::is_literal

    fn Properties::is_literal(self : Properties) -> Bool

    Return true if and only if this HIR is a simple literal.

    Properties::is_utf8

    fn Properties::is_utf8(self : Properties) -> Bool

    Return true if and only if the corresponding HIR will always match valid UTF-8.

    Properties::look_set

    fn Properties::look_set(self : Properties) -> LookSet

    Returns a set of all look-around assertions that appear at least once in this HIR value.

    Properties::look_set_prefix

    fn Properties::look_set_prefix(self : Properties) -> LookSet

    Returns a set of all look-around assertions that appear as a prefix for this HIR value.

    Properties::look_set_prefix_any

    fn Properties::look_set_prefix_any(self : Properties) -> LookSet

    Returns a set of all look-around assertions that appear as a possible prefix for this HIR value.

    Properties::look_set_suffix

    fn Properties::look_set_suffix(self : Properties) -> LookSet

    Returns a set of all look-around assertions that appear as a suffix for this HIR value.

    Properties::look_set_suffix_any

    fn Properties::look_set_suffix_any(self : Properties) -> LookSet

    Returns a set of all look-around assertions that appear as a possible suffix for this HIR value.

    Properties::maximum_len

    fn Properties::maximum_len(self : Properties) -> UInt64?

    Returns the length (in bytes) of the longest string matched by this HIR.

    Properties::minimum_len

    fn Properties::minimum_len(self : Properties) -> UInt64?

    Returns the length (in bytes) of the smallest string matched by this HIR.

    Properties::static_explicit_captures_len

    fn Properties::static_explicit_captures_len(self : Properties) -> UInt64?

    Returns the total number of explicit capturing groups that appear in every possible match.

    Properties::union

    fn Properties::union(props : Array[Properties]) -> Properties

    Create a new set of HIR properties that represents the union of the given properties.

    This is useful when one has multiple Hir expressions and wants to combine them into a single alternation without constructing the corresponding Hir. This routine provides a way of combining the properties of each Hir expression into one set of properties representing the union of those expressions.

    Repetition

    pub(all) struct Repetition {
    min : UInt
    max : UInt?
    greedy : Bool
    sub : Hir
    } derive(Eq,
    Debug
    )

    The high-level intermediate representation of a repetition operator.

    Repetition::with_sub

    fn Repetition::with_sub(self : Repetition, sub : Hir) -> Repetition

    Returns a new repetition with the same min, max and greedy values, but with its sub-expression replaced with the one given.

    SimpleCaseFolder

    pub struct SimpleCaseFolder {
    // private fields
    }

    A state oriented traverser of the simple case folding table.

    A case folder can be constructed via SimpleCaseFolder::new(), which will return an error if the underlying case folding table is unavailable.

    After construction, it is expected that callers will use SimpleCaseFolder::mapping by calling it with codepoints in strictly increasing order. For example, calling it on b and then on a is illegal and will result in a panic.

    SimpleCaseFolder::mapping

    fn SimpleCaseFolder::mapping(self : SimpleCaseFolder, c : Int) -> FixedArray[Int]

    Return the equivalence class of case folded codepoints for the given codepoint. The equivalence class returned never includes the codepoint given. If the given codepoint has no case folded codepoints (i.e., no entry in the underlying case folding table), then this returns an empty slice.

    Panics

    This panics when called with a c that is less than or equal to the previous call. In other words, callers need to use this method with strictly increasing values of c.

    SimpleCaseFolder::new

    Create a new simple case folder, returning an error if the underlying case folding table is unavailable.

    SimpleCaseFolder::overlaps

    fn SimpleCaseFolder::overlaps(self : SimpleCaseFolder, start : Int, end : Int) -> Bool

    Returns true if and only if the given range overlaps with any region of the underlying case folding table. That is, when true, there exists at least one codepoint in the inclusive range [start, end] that has a non-trivial equivalence class of case folded codepoints. Conversely, when this returns false, all codepoints in the range [start, end] correspond to the trivial equivalence class of case folded codepoints, i.e., itself.

    Panics

    This panics when end < start.

    Translator

    pub struct Translator {
    // private fields
    }

    A translator maps abstract syntax to a high level intermediate representation.

    A translator may be benefit from reuse. That is, a translator can translate many abstract syntax trees. Like upstream, its stack and active flags persist across calls to translate.

    Translator::new

    fn Translator::new() -> Translator

    Create a new translator using the default configuration.

    Translator::translate

    fn Translator::translate(self : Translator, pattern : String, ast :
    Ast
    ) -> Hir raise HirError

    Translate the given abstract syntax tree (AST) into a high level intermediate representation (HIR).

    If there was a problem doing the translation, then an HIR-specific error is returned.

    The original pattern string used to produce the Ast must also be provided. The translator does not use the pattern string during any correct translation, but is used for error reporting.

    TranslatorBuilder

    pub struct TranslatorBuilder {
    // private fields
    }

    A builder for constructing an AST->HIR translator.

    TranslatorBuilder::build

    Build a translator using the current configuration.

    TranslatorBuilder::case_insensitive

    fn TranslatorBuilder::case_insensitive(self : TranslatorBuilder, yes : Bool) -> TranslatorBuilder

    Enable or disable the case insensitive flag (i) by default.

    TranslatorBuilder::crlf

    fn TranslatorBuilder::crlf(self : TranslatorBuilder, yes : Bool) -> TranslatorBuilder

    Enable or disable the CRLF mode flag (R) by default.

    TranslatorBuilder::dot_matches_new_line

    fn TranslatorBuilder::dot_matches_new_line(self : TranslatorBuilder, yes : Bool) -> TranslatorBuilder

    Enable or disable the "dot matches any character" flag (s) by default.

    TranslatorBuilder::line_terminator

    fn TranslatorBuilder::line_terminator(self : TranslatorBuilder, byte : Byte) -> TranslatorBuilder

    Sets the line terminator for use with (?u-s:.) and (?-us:.).

    TranslatorBuilder::multi_line

    fn TranslatorBuilder::multi_line(self : TranslatorBuilder, yes : Bool) -> TranslatorBuilder

    Enable or disable the multi-line matching flag (m) by default.

    TranslatorBuilder::new

    Create a new translator builder with a default configuration.

    TranslatorBuilder::swap_greed

    fn TranslatorBuilder::swap_greed(self : TranslatorBuilder, yes : Bool) -> TranslatorBuilder

    Enable or disable the "swap greed" flag (U) by default.

    TranslatorBuilder::unicode

    fn TranslatorBuilder::unicode(self : TranslatorBuilder, yes : Bool) -> TranslatorBuilder

    Enable or disable the Unicode flag (u) by default.

    TranslatorBuilder::utf8

    fn TranslatorBuilder::utf8(self : TranslatorBuilder, yes : Bool) -> TranslatorBuilder

    When disabled, translation will permit the construction of a regular expression that may match invalid UTF-8.

    When enabled (the default), the translator is guaranteed to produce an expression that, for non-empty matches, will only ever produce spans that are entirely valid UTF-8 (otherwise, the translator will return an error).

    class

    fn class(query : ClassQuery) -> ClassUnicode raise UnicodeError

    Looks up a Unicode class given a query. If one doesn't exist, then None is returned.

    encode_utf8_into

    fn encode_utf8_into(cp : Int, out : Array[Byte]) -> Unit

    Append the UTF-8 encoding of code point cp to out.

    from_utf8

    fn from_utf8(v : BytesView) -> Array[Char] raise Utf8Error

    Rust core::str::from_utf8: the decoded code points, or the error run_utf8_validation reports.

    hir_class

    fn hir_class(ranges : Array[(Int, Int)]) -> ClassUnicode

    Build a Unicode HIR class from a sequence of Unicode scalar value ranges.

    is_word_character

    fn is_word_character(c : Int) -> Bool

    Returns true only if the given codepoint is in the \w character class.

    len_utf8

    fn len_utf8(cp : Int) -> Int

    Rust char::len_utf8 for a code point.

    perl_digit

    fn perl_digit() -> ClassUnicode raise UnicodeError

    Returns a Unicode aware class for \d.

    This returns an error if the data is not available for \d.

    perl_space

    fn perl_space() -> ClassUnicode raise UnicodeError

    Returns a Unicode aware class for \s.

    This returns an error if the data is not available for \s.

    perl_word

    fn perl_word() -> ClassUnicode raise UnicodeError

    Returns a Unicode aware class for \w.

    This returns an error if the data is not available for \w.

    utf8_decode

    fn utf8_decode(bytes : BytesView) -> Result[Int, Byte]?

    debug::utf8_decode: decode the first UTF-8 encoded code point in bytes.

    If no valid encoding of a code point exists at the beginning of the given byte slice, then the first byte is returned instead. If bytes is empty, None is returned.

    utf8_encode

    fn utf8_encode(s : String) -> Array[Byte]

    Encode s as UTF-8.