Token

public struct Token : Sendable

A terminal symbol of the syntactic grammar.

  • The kind of a token.

    See more

    Declaration

    Swift

    public enum Kind : Int, Sendable
  • The kind of the token.

    Declaration

    Swift

    public internal(set) var kind: Kind { get }
  • The site from which self was extracted.

    Declaration

    Swift

    public internal(set) var site: SourceRange { get }
  • Indicates whether self is a keyword.

    Declaration

    Swift

    public var isKeyword: Bool { get }
  • Indicates whether self is a suitable as a label.

    Declaration

    Swift

    public var isLabel: Bool { get }
  • Indicates whether self may be in an operator.

    Operators may be represented by one or more tokens. For example, << is represented by two consecutive .lAngle tokens. Use this property to determine whether self may be a token in such a sequence.

    Declaration

    Swift

    public var isOperatorPart: Bool { get }
  • Indicates whether self is a suitable prefix operator head.

    Note

    & may not be at the start of a prefix operator. An expression prefixed by & is parsed as an in-place expression.

    Declaration

    Swift

    public var isPrefixOperatorHead: Bool { get }
  • Indicates whether self is a suitable postfix operator head.

    Declaration

    Swift

    public var isPostfixOperatorHead: Bool { get }
  • Indicates whether self is a declaration modifier.

    Declaration

    Swift

    public var isDeclModifier: Bool { get }
  • Indicates whether self may be at the beginning of a declaration.

    Declaration

    Swift

    public var mayBeginDecl: Bool { get }
  • Indicates whether self may be at the beginning of a control statement.

    Declaration

    Swift

    public var mayBeginCtrlStmt: Bool { get }
  • Returns whether self.kind is contained in kinds.

    Declaration

    Swift

    public func isOf<T>(kind kinds: T) -> Bool where T : Collection, T.Element == Token.Kind

    Parameters

    kinds

    A list of kinds.