TokenType

public protocol TokenType

TokenTypes are generated when rules are matched (usually, sometime a rule just advances the scan-head). Tokens with a rawValue of -1 are considered transient, meaning that they should not be included in any construction of an AST. However, they may provide context to the AST.

  • A rawValue that unless the token is transient should be unique

    Declaration

    Swift

    var rawValue: Int { get }
  • from(_:) Extension method

    Creates an instance of the rule producer that will generate the token when satisfied

    Declaration

    Swift

    public func from(_ rule: Rule) -> Rule

    Parameters

    rule

    The rule (or thing that can become a rule)

    Return Value

    A rule

  • ==(_:_:) Extension method

    Undocumented

    Declaration

    Swift

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