Files
Lyrebird/Sources/LyrebirdGraphDSL/DSLToken.swift
T

44 lines
1.1 KiB
Swift

// DSLToken.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
// A lexed token: a kind, the source text it covers, and its span.
/// One token produced by ``DSLLexer``.
public struct DSLToken: Equatable, Sendable {
/// The lexical categories the DSL recognises.
public enum Kind: Equatable, Sendable {
case identifier
case number
case leftParen
case rightParen
case comma
case colon
case dot
case equals
case plus
case minus
case star
case slash
/// A statement separator (one or more newlines collapsed).
case newline
/// End of input.
case eof
}
public let kind: Kind
/// The exact source text (identifier name, number literal, …). Empty for
/// punctuation / newline / eof.
public let text: String
public let span: DSLSpan
public init(kind: Kind, text: String, span: DSLSpan) {
self.kind = kind
self.text = text
self.span = span
}
}