25 lines
720 B
Swift
25 lines
720 B
Swift
// DSLSpan.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// A half-open character range into DSL source, carried by tokens and AST nodes
|
|
// so parse/build errors can point at the offending text.
|
|
|
|
/// A `[start, end)` range in *character* offsets into the DSL source string.
|
|
public struct DSLSpan: Equatable, Sendable {
|
|
public let start: Int
|
|
public let end: Int
|
|
|
|
public init(start: Int, end: Int) {
|
|
self.start = start
|
|
self.end = end
|
|
}
|
|
|
|
/// A zero-length span at `offset` (for end-of-input / synthetic positions).
|
|
public static func point(_ offset: Int) -> DSLSpan {
|
|
DSLSpan(start: offset, end: offset)
|
|
}
|
|
}
|