1// SPDX-FileCopyrightText: 2025 The Project Pterodactyl Developers 2// 3// SPDX-License-Identifier: MPL-2.0 4 5import Foundation 6import LanguageServerProtocol 7 8public enum Keyword: String, Codable, Sendable, CaseIterable { 9 case theory = "theory" 10 case `where` = "where" 11 case `import` = "import" 12} 13 14public enum Punctuation: String, CaseIterable, Codable, Equatable, Sendable { 15 case lparen = "(" 16 case rparen = ")" 17 case lbrace = "{" 18 case rbrace = "}" 19 case comma = "," 20 case dot = "." 21 case colon = ":" 22 case doubleLeftArrow = "<=" 23 case doubleRightArrow = "=>" 24 case equal = "=" 25} 26 27public enum TokenKind: Codable, Equatable, Sendable { 28 case eof 29 case keyword(Keyword) 30 case punctuation(Punctuation) 31 case error 32 case identifier 33 case newline 34 case whitespace 35 case blockBegin 36 case blockEnd 37 case blockSep 38 case lineComment 39 case blockComment(terminated: Bool) 40} 41 42extension TokenKind { 43 public var isTrivia: Bool { 44 switch self { 45 case .whitespace, .newline, .lineComment, .blockComment: true 46 default: false 47 } 48 } 49 50 public var isVisible: Bool { 51 switch self { 52 case .whitespace, .blockBegin, .blockSep, .blockEnd, .newline: false 53 default: true 54 } 55 } 56 public var canDetermineLayoutColumn: Bool { 57 switch self { 58 case .whitespace, .eof: false 59 default: true 60 } 61 } 62 63 public var isBlockHerald: Bool { 64 switch self { 65 case .keyword(.where): true 66 default: false 67 } 68 } 69 70} 71 72public final class SyntaxTreeKind: Codable, Equatable, Sendable { 73 static let error: SyntaxTreeKind = .init(name: "error") 74 75 public static func == (lhs: SyntaxTreeKind, rhs: SyntaxTreeKind) -> Bool { 76 lhs === rhs 77 } 78 79 let name: String 80 var description: String { name } 81 82 required init(name: String) { 83 self.name = name 84 } 85} 86 87public struct TokenMetadata: Equatable, Codable, Sendable { 88 public var semanticTokenType: SemanticTokenTypes 89 public var semanticTokenModifiers: Set<SemanticTokenModifiers> = [] 90 public var delimitedFoldingRangeKind: FoldingRangeKind? = nil 91} 92 93public struct SyntaxTreeMetadata: Codable, Equatable, Sendable { 94 public var delimitedFoldingRangeKind: FoldingRangeKind? = nil 95}