From 6242d196fd7455babcbb1303d3d9942569a53b66 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 1 Nov 2024 17:05:36 -0700 Subject: [PATCH] Updates for Swift 6 --- Package.resolved | 5 +-- Package.swift | 4 +-- .../Utils/DebugGrammarParser.citron | 2 +- .../Utils/DebugGrammarScanner.swift | 33 ++++++++++--------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Package.resolved b/Package.resolved index e0115a4..105dd60 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,4 +1,5 @@ { + "originHash" : "d1e34fdb2ca25d057f59ed9573c5bc295cbcdaed69e42def6d10243b96f90b79", "pins" : [ { "identity" : "citron", @@ -6,7 +7,7 @@ "location" : "https://github.com/dabrahams/citron.git", "state" : { "revision" : "d19a40c8de65b68fec0d224576d60565c1f7ccf1", - "version" : "2.1.5" + "version" : "2.1.7" } }, { @@ -28,5 +29,5 @@ } } ], - "version" : 2 + "version" : 3 } diff --git a/Package.swift b/Package.swift index b333d63..f11db25 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.7 +// swift-tools-version: 6.0 import PackageDescription import Foundation @@ -26,7 +26,7 @@ let package = Package( targets: ["Lotsawa"]), ], dependencies: [ - .package(url: "https://github.com/dabrahams/citron.git", from: "2.1.5"), + .package(url: "https://github.com/dabrahams/citron.git", from: "2.1.7"), .package(url: "https://github.com/SwiftPackageIndex/SPIManifest.git", from: "0.12.0") ] + docGenerationDependency, diff --git a/Tests/LotsawaTests/Utils/DebugGrammarParser.citron b/Tests/LotsawaTests/Utils/DebugGrammarParser.citron index 8bd6fbd..512905b 100644 --- a/Tests/LotsawaTests/Utils/DebugGrammarParser.citron +++ b/Tests/LotsawaTests/Utils/DebugGrammarParser.citron @@ -4,7 +4,7 @@ import CitronParserModule import CitronLexerModule - extension _CitronParserUnexpectedTokenError : CustomDebugStringConvertible { + extension _CitronParserUnexpectedTokenError : @retroactive CustomDebugStringConvertible { public var debugDescription: String { if let t = token as? DebugGrammar.AST.Token { return "\n\(t.position): error: unexpected token (\(t), tokenCode: \(tokenCode))" diff --git a/Tests/LotsawaTests/Utils/DebugGrammarScanner.swift b/Tests/LotsawaTests/Utils/DebugGrammarScanner.swift index 8b1027f..1219fca 100644 --- a/Tests/LotsawaTests/Utils/DebugGrammarScanner.swift +++ b/Tests/LotsawaTests/Utils/DebugGrammarScanner.swift @@ -6,22 +6,23 @@ import CitronLexerModule let comment = #"(?://\P{Bidi_Class=B}*)"# /// A lexical analyzer for the grammar we use to describe other grammars for testing. -let testGrammarScanner = Scanner( - literalStrings: [ - "::=": .IS_DEFINED_AS, - "_": .UNDERSCORE, - "|": .ALTERNATION, - ], - patterns: [ - /// A mapping from regular expression pattern to either a coresponding token ID, - /// or `nil` if the pattern is to be discarded (e.g. for whitespace). - #"[A-Za-z][-_A-Za-z0-9]*(?=\s*::=)"#: .LHS, - #"[A-Za-z][-_A-Za-z0-9]*(?!\s*::=)"#: .SYMBOL, - #"'([^\\']|\\.)*'"#: .LITERAL, - #"\s*"#: nil, - comment: nil, - ] -) +var testGrammarScanner : Scanner { + return .init( + literalStrings: [ + "::=": .IS_DEFINED_AS, + "_": .UNDERSCORE, + "|": .ALTERNATION, + ], + patterns: [ + /// A mapping from regular expression pattern to either a coresponding token ID, + /// or `nil` if the pattern is to be discarded (e.g. for whitespace). + #"[A-Za-z][-_A-Za-z0-9]*(?=\s*::=)"#: .LHS, + #"[A-Za-z][-_A-Za-z0-9]*(?!\s*::=)"#: .SYMBOL, + #"'([^\\']|\\.)*'"#: .LITERAL, + #"\s*"#: nil, + comment: nil, + ]) +} extension DebugGrammar.AST {