Consumer
public indirect enum Consumer<Label> : Equatable, Sendable where Label : Hashable, Label : Sendable
extension Consumer: ExpressibleByStringLiteral, ExpressibleByArrayLiteral
extension Consumer: CustomStringConvertible
Undocumented
-
Primitives
Declaration
Swift
case string(String) -
Undocumented
Declaration
Swift
case charset(Charset) -
Combinators
Declaration
Swift
case any([Consumer]) -
Undocumented
Declaration
Swift
case sequence([Consumer]) -
Undocumented
Declaration
Swift
case optional(Consumer) -
Undocumented
Declaration
Swift
case oneOrMore(Consumer) -
Undocumented
Declaration
Swift
case not(Consumer) -
Transforms
Declaration
Swift
case flatten(Consumer) -
Undocumented
Declaration
Swift
case discard(Consumer) -
Undocumented
Declaration
Swift
case replace(Consumer, String) -
References
Declaration
Swift
case label(Label, Consumer) -
Undocumented
Declaration
Swift
case reference(Label)
-
Parse input and return matched result
Declaration
Swift
func match(_ input: String) throws -> Match -
Will the consumer match empty input?
Declaration
Swift
var isOptional: Bool { get } -
Source location
See moreDeclaration
-
Abstract syntax tree returned by consumer
See moreDeclaration
-
Opaque type used for efficient character matching
See moreDeclaration
Swift
struct Charset : Hashable, Sendable -
Closure for transforming a Match to an application-specific data type
Declaration
Swift
typealias Transform = (_ name: Label, _ values: [Sendable]) throws -> (Sendable)? -
A Parsing error
See moreDeclaration
-
Create .string() consumer from a string literal
Declaration
Swift
public init(stringLiteral: String) -
Create .sequence() consumer from an array literal
Declaration
Swift
public init(arrayLiteral: Consumer...) -
Converts two consumers into an .any() consumer
Declaration
Swift
public static func | (lhs: Consumer, rhs: Consumer) -> Consumer
-
Match a character
Declaration
Swift
static func character(_ c: UnicodeScalar) -> Consumer -
Match character in range
Declaration
Swift
static func character(in range: ClosedRange<UnicodeScalar>) -> Consumer -
Match character in string
Declaration
Swift
static func character(in string: String) -> Consumer -
Match character in set
Declaration
Swift
static func character(in set: CharacterSet) -> Consumer -
Match any character except the one(s) specified
Declaration
Swift
static func anyCharacter(except characters: UnicodeScalar...) -> Consumer -
Match any character except the specified set
Declaration
Swift
static func anyCharacter(except set: CharacterSet) -> Consumer
-
Matches a list of zero or more
consumerinstancesDeclaration
Swift
static func zeroOrMore(_ consumer: Consumer) -> Consumer -
Matches one or more
consumerinstances, separated by an instance ofseparatorThis is useful for something like a comma-delimited list (without a trailing comma)Declaration
Swift
static func interleaved(_ consumer: Consumer, _ separator: Consumer) -> Consumer -
Matches the
targetconsumer, ignoring any instances of theignoredconsumer This is useful for something like ignoring whitespace between tokens Note: Instances ofignoredinsideflattenclauses will not be ignoredDeclaration
Swift
static func ignore(_ ignored: Consumer, in target: Consumer) -> Consumer
-
Human-readable description of what consumer matches
Declaration
Swift
public var description: String { get }
View on GitHub
Install in Dash
Consumer Enumeration Reference