Functions

The following functions are available globally.

  • This is where the Matcher is able to determine the MatchResult for a given input inside the provided substring range

    Declaration

    Swift

    internal func matchStatement<T, E>(amongst statements: [Pattern<T, E>], in input: String, from start: String.Index? = nil, interpreter: E, context: Context, connectedRanges: [ClosedRange<String.Index>] = []) -> MatchResult<T> where E : Interpreter

    Parameters

    amongst

    All the Matcher instances to evaluate, in priority order

    in

    The input

    from

    The start of the checked range

    interpreter

    An interpreter instance - if variables need any further evaluation

    context

    The context - if variables need any contextual information

    connectedRanges

    Ranges of string indices that are connected with opening-closing tag pairs, respectively

    Return Value

    The result of the match operation

  • Independent helper function that determines the pairs of opening and closing keywords

    Declaration

    Swift

    internal func collectConnectedRanges(input: String, statements: [Pattern<Any, TypedInterpreter>]) -> [ClosedRange<String.Index>]

    Parameters

    input

    The input string to search ranges in

    statements

    Patterns that contain the opening and closing keyword types that should be matched

    Return Value

    The ranges of opening-closing pairs, keeping logical hierarchy

  • Syntactic sugar for MatchElement instances to feel like concatenation, whenever the input requires an array of elements.

    Declaration

    Swift

    public func + (left: PatternElement, right: PatternElement) -> [PatternElement]

    Parameters

    left

    Left hand side

    right

    Right hand side

    Return Value

    An array with two elements (left and right in this order)

  • Syntactic sugar for appended arrays

    Declaration

    Swift

    internal func + <A>(array: [A], element: A) -> [A]

    Parameters

    array

    The array to append

    element

    The appended element

    Return Value

    A new array by appending array with element

  • Syntactic sugar for appending mutable arrays

    Declaration

    Swift

    internal func += <A>(array: inout [A], element: A)

    Parameters

    array

    The array to append

    element

    The appended element