Skip to content
kareman edited this page Jul 1, 2020 · 4 revisions

OneOf

Matches and consumes a single element.

public struct OneOf: Pattern, RegexConvertible

Inheritance

OneOfConvertible, Pattern, RegexConvertible

Initializers

init(description:regex:group:)

@usableFromInline init(description: String, regex: String? = nil, group: Group<Input.Element>)

init(description:regex:contains:)

Matches any element for which contains returns true.

@inlinable public init(description: String, regex: String? = nil, contains: @escaping (Input.Element) -> Bool)

Parameters

  • description: - description: A descriptive identifier for textual representation of the pattern.
  • regex: - regex: An optional regex matching the same elements.
  • contains: - contains: A closure returning true for any element that matches.

init(_:)

Matches any elements in elements.

@inlinable public init<S: Sequence>(_ elements: S) where S.Element == Input.Element

Parameters

  • elements: - elements: A sequence of elements to match.

init(not:)

Matches any elements not in elements.

@inlinable public init<S: Sequence>(not elements: S) where S.Element == Input.Element

Parameters

  • elements: - elements: A sequence of elements not to match.

init(_:)

Matches any of the provided elements.

@inlinable public init(_ oneofs: OneOfConvertible)

init(not:)

Matches anything that is not among the provided elements.

@inlinable public init(not oneofs: OneOfConvertible)

Properties

group

let group: Group<Input.Element>

description

let description: String

_regex

let _regex: String?

regex

var regex: String

patterns

Predefined OneOf patterns.

let patterns: [OneOf]

Methods

createInstructions(_:)

@inlinable public func createInstructions(_ instructions: inout Instructions)

contains(_:)

@inlinable public func contains(_ char: Pattern.Input.Element) -> Bool

patterns(for:)

All the predefined OneOf patterns that match element.

public static func patterns(for element: Input.Element) -> [OneOf]

patterns(for:)

The predefined OneOf patterns that match all the elements in sequence.

public static func patterns<S: Sequence>(for sequence: S) -> [OneOf] where S.Element == Input.Element
Clone this wiki locally