Skip to content

Disable resilience on _RegexParser #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ let availabilityDefinition = PackageDescription.SwiftSetting.unsafeFlags([
"-Xfrontend",
"-define-availability",
"-Xfrontend",
#"SwiftStdlib 5.7:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999"#,
"SwiftStdlib 5.7:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999",
])

let stdlibSettings: [PackageDescription.SwiftSetting] = [
/// Swift settings for building a private stdlib-like module that is to be used
/// by other stdlib-like modules only.
let privateStdlibSettings: [PackageDescription.SwiftSetting] = [
.unsafeFlags(["-Xfrontend", "-disable-implicit-concurrency-module-import"]),
.unsafeFlags(["-Xfrontend", "-disable-implicit-string-processing-module-import"]),
]

/// Swift settings for building a user-facing stdlib-like module.
let publicStdlibSettings: [PackageDescription.SwiftSetting] = [
.unsafeFlags(["-enable-library-evolution"]),
.unsafeFlags(["-Xfrontend", "-disable-implicit-concurrency-module-import"]),
.unsafeFlags(["-Xfrontend", "-disable-implicit-string-processing-module-import"]),
Expand Down Expand Up @@ -43,7 +51,7 @@ let package = Package(
.target(
name: "_RegexParser",
dependencies: [],
swiftSettings: stdlibSettings),
swiftSettings: privateStdlibSettings),
.testTarget(
name: "MatchingEngineTests",
dependencies: [
Expand All @@ -55,11 +63,11 @@ let package = Package(
.target(
name: "_StringProcessing",
dependencies: ["_RegexParser", "_CUnicode"],
swiftSettings: stdlibSettings),
swiftSettings: publicStdlibSettings),
.target(
name: "RegexBuilder",
dependencies: ["_StringProcessing", "_RegexParser"],
swiftSettings: stdlibSettings),
swiftSettings: publicStdlibSettings),
.testTarget(
name: "RegexTests",
dependencies: ["_StringProcessing"],
Expand Down
2 changes: 0 additions & 2 deletions Sources/_RegexParser/Regex/AST/AST.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ extension AST {

extension AST {
/// A node in the regex AST.
@frozen
public indirect enum Node:
Hashable, _TreeNode //, _ASTPrintable ASTValue, ASTAction
{
Expand Down Expand Up @@ -249,7 +248,6 @@ extension AST {
}

public struct Reference: Hashable {
@frozen
public enum Kind: Hashable {
// \n \gn \g{n} \g<n> \g'n' (?n) (?(n)...
// Oniguruma: \k<n>, \k'n'
Expand Down
5 changes: 0 additions & 5 deletions Sources/_RegexParser/Regex/AST/Atom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ extension AST {
self.location = loc
}

@frozen
public enum Kind: Hashable {
/// Just a character
///
Expand Down Expand Up @@ -146,7 +145,6 @@ extension AST.Atom {

// Characters, character types, literals, etc., derived from
// an escape sequence.
@frozen
public enum EscapedBuiltin: Hashable {
// TODO: better doc comments

Expand Down Expand Up @@ -399,7 +397,6 @@ extension AST.Atom {
}

extension AST.Atom.CharacterProperty {
@frozen
public enum Kind: Hashable {
/// Matches any character, equivalent to Oniguruma's '\O'.
case any
Expand Down Expand Up @@ -438,7 +435,6 @@ extension AST.Atom.CharacterProperty {
}

// TODO: erm, separate out or fold into something? splat it in?
@frozen
public enum PCRESpecialCategory: String, Hashable {
case alphanumeric = "Xan"
case posixSpace = "Xps"
Expand All @@ -450,7 +446,6 @@ extension AST.Atom.CharacterProperty {

extension AST.Atom {
/// Anchors and other built-in zero-width assertions.
@frozen
public enum AssertionKind: String {
/// \A
case startOfSubject = #"\A"#
Expand Down
3 changes: 0 additions & 3 deletions Sources/_RegexParser/Regex/AST/CustomCharClass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ extension AST {
self.location = sr
}

@frozen
public enum Member: Hashable {
/// A nested custom character class `[[ab][cd]]`
case custom(CustomCharacterClass)
Expand Down Expand Up @@ -59,13 +58,11 @@ extension AST {
self.rhs = rhs
}
}
@frozen
public enum SetOp: String, Hashable {
case subtraction = "--"
case intersection = "&&"
case symmetricDifference = "~~"
}
@frozen
public enum Start: String {
case normal = "["
case inverted = "[^"
Expand Down
2 changes: 0 additions & 2 deletions Sources/_RegexParser/Regex/AST/Quantification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ extension AST {
self.trivia = trivia
}

@frozen
public enum Amount: Hashable {
case zeroOrMore // *
case oneOrMore // +
Expand All @@ -47,7 +46,6 @@ extension AST {
case range(Located<Int>, Located<Int>) // {n,m}
}

@frozen
public enum Kind: String, Hashable {
case eager = ""
case reluctant = "?"
Expand Down
5 changes: 0 additions & 5 deletions Sources/_RegexParser/Utility/MissingUnicode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ extension Unicode {
// other script types.

/// Character script types.
@frozen
public enum Script: String, Hashable {
case adlam = "Adlam"
case ahom = "Ahom"
Expand Down Expand Up @@ -188,7 +187,6 @@ extension Unicode {

/// POSIX character properties not already covered by general categories or
/// binary properties.
@frozen
public enum POSIXProperty: String, Hashable {
case alnum = "alnum"
case blank = "blank"
Expand All @@ -206,7 +204,6 @@ extension Unicode {

/// Unicode.GeneralCategory + cases for "meta categories" such as "L", which
/// encompasses Lu | Ll | Lt | Lm | Lo.
@frozen
public enum ExtendedGeneralCategory: String, Hashable {
case other = "C"
case control = "Cc"
Expand Down Expand Up @@ -257,7 +254,6 @@ extension Unicode {
/// A list of Unicode properties that can either be true or false.
///
/// https://www.unicode.org/Public/UCD/latest/ucd/PropertyAliases.txt
@frozen
public enum BinaryProperty: String, Hashable {
case asciiHexDigit = "ASCII_Hex_Digit"
case alphabetic = "Alphabetic"
Expand Down Expand Up @@ -333,7 +329,6 @@ extension Unicode {
// property.

/// Oniguruma properties that are not covered by Unicode spellings.
@frozen
public enum OnigurumaSpecialProperty: String, Hashable {
case inBasicLatin = "In_Basic_Latin"
case inLatin1Supplement = "In_Latin_1_Supplement"
Expand Down
3 changes: 0 additions & 3 deletions Sources/_StringProcessing/MatchingOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ extension MatchingOptions {
// Whitespace options are only relevant during parsing, not compilation.
case .extended, .extraExtended:
return nil
@unknown default:
// Ignore unknown
return nil
}
}

Expand Down
2 changes: 0 additions & 2 deletions Sources/_StringProcessing/Regex/DSLTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,6 @@ extension DSLTree.Node {
child._addCaptures(to: &list, optionalNesting: nesting)
case .clearer, .repeater, .stopper:
break
@unknown default:
fatalError()
}

case let .convertedRegexLiteral(n, _):
Expand Down
1 change: 0 additions & 1 deletion Tests/RegexBuilderTests/AlgorithmsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import XCTest
import _StringProcessing
import RegexBuilder

@available(SwiftStdlib 5.7, *)
class RegexConsumerTests: XCTestCase {
func testMatches() {
let regex = Capture(OneOrMore(.digit)) { 2 * Int($0)! }
Expand Down