Skip to content

Commit 17f1cf9

Browse files
authored
Merge pull request swiftlang#40240 from rxwei/string-processing-module
2 parents 52eb046 + 65bffd7 commit 17f1cf9

File tree

25 files changed

+201
-12
lines changed

25 files changed

+201
-12
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
445445
"Enable experimental distributed actors and functions"
446446
FALSE)
447447

448+
option(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING
449+
"Enable experimental string processing"
450+
FALSE)
451+
448452
option(SWIFT_ENABLE_DISPATCH
449453
"Enable use of libdispatch"
450454
TRUE)
@@ -997,6 +1001,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
9971001
message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
9981002
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
9991003
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
1004+
message(STATUS "String Processing Support: ${SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING}")
10001005
message(STATUS "")
10011006
else()
10021007
message(STATUS "Not building Swift standard library, SDK overlays, and runtime")

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ namespace swift {
145145
version::Version PackageDescriptionVersion;
146146

147147
/// Enable experimental string processing
148-
bool EnableExperimentalRegex = false;
148+
bool EnableExperimentalStringProcessing = false;
149149

150150
/// Disable API availability checking.
151151
bool DisableAvailabilityChecking = false;

include/swift/Option/FrontendOptions.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ def disable_deserialization_recovery :
475475
Flag<["-"], "disable-deserialization-recovery">,
476476
HelpText<"Don't attempt to recover from missing xrefs (etc) in swiftmodules">;
477477

478-
def enable_experimental_regex :
479-
Flag<["-"], "enable-experimental-regex">,
478+
def enable_experimental_string_processing :
479+
Flag<["-"], "enable-experimental-string-processing">,
480480
HelpText<"Enable experimental string processing">;
481481

482482
def disable_availability_checking : Flag<["-"],

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
473473
}
474474

475475
// Experimental string processing
476-
Opts.EnableExperimentalRegex |=
477-
Args.hasArg(OPT_enable_experimental_regex);
476+
Opts.EnableExperimentalStringProcessing |=
477+
Args.hasArg(OPT_enable_experimental_string_processing);
478478

479479
Opts.DisableAvailabilityChecking |=
480480
Args.hasArg(OPT_disable_availability_checking);

lib/Parse/Lexer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ void Lexer::diagnoseSingleQuoteStringLiteral(const char *TokStart,
18071807
auto startLoc = Lexer::getSourceLoc(TokStart);
18081808
auto endLoc = Lexer::getSourceLoc(TokEnd);
18091809

1810-
if (LangOpts.EnableExperimentalRegex) {
1810+
if (LangOpts.EnableExperimentalStringProcessing) {
18111811
if (parseRegexStrawperson) {
18121812
auto copy = std::string(TokStart, TokEnd-TokStart);
18131813
auto msg = parseRegexStrawperson(copy.c_str());

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ function(_add_target_variant_swift_compile_flags
285285
list(APPEND result "-D" "SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING")
286286
endif()
287287

288+
if(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING)
289+
list(APPEND result "-D" "SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING")
290+
endif()
291+
288292
if(SWIFT_STDLIB_OS_VERSIONING)
289293
list(APPEND result "-D" "SWIFT_RUNTIME_OS_VERSIONING")
290294
endif()

stdlib/public/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ if(SWIFT_BUILD_STDLIB)
115115
if(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED)
116116
add_subdirectory(Distributed)
117117
endif()
118+
119+
if(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING)
120+
add_subdirectory(MatchingEngine)
121+
add_subdirectory(StringProcessing)
122+
endif()
118123
endif()
119124

120125
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#===--- CMakeLists.txt - Pattern matching engine support library -----------===#
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2021 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
#===------------------------------------------------------------------------===#
12+
13+
set(swift_matching_engine_link_libraries
14+
swiftCore)
15+
16+
17+
add_swift_target_library(swift_MatchingEngine ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
18+
MatchingEngine.swift
19+
20+
SWIFT_MODULE_DEPENDS_LINUX Glibc
21+
SWIFT_MODULE_DEPENDS_FREEBSD Glibc
22+
SWIFT_MODULE_DEPENDS_OPENBSD Glibc
23+
SWIFT_MODULE_DEPENDS_CYGWIN Glibc
24+
SWIFT_MODULE_DEPENDS_HAIKU Glibc
25+
SWIFT_MODULE_DEPENDS_WINDOWS CRT
26+
27+
LINK_LIBRARIES ${swift_matching_engine_link_libraries}
28+
29+
C_COMPILE_FLAGS
30+
-Dswift_MatchingEngine_EXPORTS
31+
SWIFT_COMPILE_FLAGS
32+
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
33+
-parse-stdlib
34+
-Xfrontend -enable-experimental-string-processing
35+
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
36+
37+
INSTALL_IN_COMPONENT stdlib
38+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Swift
2+
3+
public struct DummyMatchingEngine {
4+
public init() {
5+
fatalError("Unimplemented")
6+
}
7+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#===--- CMakeLists.txt - String processing support library -----------------===#
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2021 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
#===------------------------------------------------------------------------===#
12+
13+
set(swift_string_processing_link_libraries
14+
swiftCore
15+
swift_MatchingEngine)
16+
17+
18+
add_swift_target_library(swift_StringProcessing ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
19+
Regex.swift
20+
21+
SWIFT_MODULE_DEPENDS_LINUX Glibc
22+
SWIFT_MODULE_DEPENDS_FREEBSD Glibc
23+
SWIFT_MODULE_DEPENDS_OPENBSD Glibc
24+
SWIFT_MODULE_DEPENDS_CYGWIN Glibc
25+
SWIFT_MODULE_DEPENDS_HAIKU Glibc
26+
SWIFT_MODULE_DEPENDS_WINDOWS CRT
27+
28+
LINK_LIBRARIES ${swift_string_processing_link_libraries}
29+
30+
C_COMPILE_FLAGS
31+
-Dswift_StringProcessing_EXPORTS
32+
SWIFT_COMPILE_FLAGS
33+
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
34+
-parse-stdlib
35+
-Xfrontend -enable-experimental-string-processing
36+
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
37+
38+
SWIFT_MODULE_DEPENDS _MatchingEngine
39+
INSTALL_IN_COMPONENT stdlib
40+
)

0 commit comments

Comments
 (0)