IndexedSymbolName

public struct IndexedSymbolName : CustomStringConvertible, Hashable

An IndexedSymbol designates either a terminal or a nonterminal.

IndexedSymbols are used to refer to terminals and nonterminals in grammar rules. In order to distinguish between different occurrences of the same terminal / nonterminal, indexed symbols carry an optional index in addition to the actual name.

  • The name of the terminal or nonterminal that this indexed symbol designates.

    Declaration

    Swift

    public let name: SymbolName
  • An optional index to distinguish between different occurrences of the same terminal / nonterminal. A value of 0 stands for this symbol having no index.

    Declaration

    Swift

    public let index: AnyHashable
  • Constructs an indexed symbol.

    Declaration

    Swift

    public init(_ name: SymbolName, _ index: AnyHashable = 0)

    Parameters

    name

    The name of this indexed symbol.

    index

    An optional index, to distinguish between different occurrences of the same terminal / nonterminal.

  • Whether this symbol has an index or not. An index of 0 counts as having no index.

    Declaration

    Swift

    public var hasIndex: Bool { get }

    Return Value

    false if index is 0, otherwise true

  • Declaration

    Swift

    public var description: String { get }