Keyword

public class Keyword : PatternElement, Equatable

Keyword instances are used to provide static points in match sequences so that they can be used as pillars of the expressions the developer tries to match

  • The type of the Keyword determines whether the item holds some special purpose, or it’s just an ordinary static String

    See more

    Declaration

    Swift

    public enum KeywordType : Equatable
  • Name (and value) of the Keyword

    Declaration

    Swift

    let name: String
  • Type of the keyword, which gives the framework some extra semantics about its nature

    Declaration

    Swift

    let type: KeywordType
  • Keyword initialiser

    Declaration

    Swift

    public init(_ name: String, type: KeywordType = .generic)

    Parameters

    name

    The name (and value) of the Keyword

    type

    Type of the keyword, which gives the framework some extra semantics about its nature. Defaults to KeywordType.generic

  • Keyword instances are returning exactMatch, when they are equal to the prefix input. If the input is really just a prefix of the keyword, possible metch is returned. noMatch otherwise.

    Declaration

    Swift

    public func matches(prefix: String, options: PatternOptions = []) -> MatchResult<Any>

    Parameters

    prefix

    The input

    options

    Options that modify the matching algorithm

    Return Value

    The result of the match operation

  • Keyword instances are Equatables

    Declaration

    Swift

    public static func == (lhs: Keyword, rhs: Keyword) -> Bool

    Parameters

    lhs

    Left hand side

    rhs

    Right hand side

    Return Value

    Whether the names and types are equal in lhs and rhs