SPB Git

spb/metrika Public

Stata-class statistics, GPU-accelerated by Apple Silicon. Native Swift — no Electron, no Python runtime, no compromises.

Swift 92.4% HTML 3.3% R 3% Shell 1.3%
1.5 KB · 56 lines swift
Raw Blame History
1//2//  Token.swift3//  Metrika4//5//  Author:  Simon-Pierre Boucher6//  Contact: contact@spboucher.ai7//  Copyright © 2026 Simon-Pierre Boucher. All rights reserved.8//910/// A lexical token of the ZQL command language, carrying its 1-based11/// source column so parse errors can point at the offending position.12public struct ZQToken: Equatable, Sendable {13    public enum Kind: Equatable, Sendable {14        case identifier(String)15        case number(Double)16        case string(String)17        case comma18        case colon19        case lparen20        case rparen21        case lbracket22        case rbracket23        /// Operators: + - * / ^ = == != < <= > >= & | ! # .24        case op(String)25        case endOfLine26    }2728    public let kind: Kind29    /// 1-based column of the first character of the token.30    public let column: Int3132    public init(kind: Kind, column: Int) {33        self.kind = kind34        self.column = column35    }36}3738extension ZQToken.Kind {39    /// Human-readable rendering used in error messages.40    public var describe: String {41        switch self {42        case .identifier(let s): return "'\(s)'"43        case .number(let n): return "number \(n)"44        case .string(let s): return "\"\(s)\""45        case .comma: return "','"46        case .colon: return "':'"47        case .lparen: return "'('"48        case .rparen: return "')'"49        case .lbracket: return "'['"50        case .rbracket: return "']'"51        case .op(let o): return "'\(o)'"52        case .endOfLine: return "end of line"53        }54    }55}56