Commit Graph

17 Commits

Author SHA1 Message Date
Rintaro Ishizaki
47f18d492e [ASTGen] Move regex literal parsing from SwiftCompilerSources to ASTGen
ASTGen always builds with the host Swift compiler, without requiring
bootstrapping, and is enabled in more places. Move the regex literal
parsing logic there so it is enabled in more host environments, and
makes use of CMake's Swift support. Enable all of the regex literal
tests when ASTGen is built, to ensure everything is working.

Remove the "AST" and "Parse" Swift modules from SwiftCompilerSources,
because they are no longer needed.
2023-11-16 10:59:23 -08:00
Rintaro Ishizaki
d292a95296 [SwiftCompiler/Regex] Use bridged DiagnosticEngine for error reporting
This fixes:
 * An issue where the diagnostic messages were leaked
 * Diagnose at correct position inside the regex literal

To do this:
 * Introduce 'Parse' SwiftCompiler module that is a bridging layer
   between '_CompilerRegexParser' and C++ libParse
 * Move libswiftParseRegexLiteral and libswiftLexRegexLiteral to 'Parse'

Also this change makes 'SwiftCompilerSources/Package.swift' be configured
by CMake so it can actually be built with 'swift-build'.

rdar://92187284
2022-04-22 22:53:46 -07:00
Richard Wei
72ebcded98 Integrate newer string processing (a0ed7e1)
Friend PR: apple/swift-experimental-string-processing#282.

Also remove the `-enable-experimental-pairwise-build-block` flag when building regex modules as the feature is already on by default.
2022-04-15 12:01:45 -07:00
Hamish Knight
f1a799037e [Parse] Introduce /.../ regex literals
Start parsing regex literals with `/.../`
delimiters.

rdar://83253726
2022-04-12 16:03:49 +01:00
Hamish Knight
63b8db1659 Start using '-enable-bare-slash-regex'
Change the flag to imply
'-enable-experimental-string-processing', and
and update some tests to start using it.
2022-04-12 16:03:47 +01:00
Hamish Knight
51130bfb07 [test] Update regex literal tests 2022-04-04 11:51:41 +01:00
Hamish Knight
cb514646cd [test] Add some additional regex parsing tests 2022-03-21 19:26:10 +00:00
Hamish Knight
611fd33f58 Update regex literal delimiters
Update the lexing code for the replacement of the
`'/.../'` and `'|...|'` delimiters with `#/.../#`
and `#|...|#` respectively, in addition to
allowing the `re'...'` delimiter.
2022-02-24 17:37:16 -08:00
Richard Wei
1b83efb512 Revert "Revert "[Regex] Switch regex match to Swift tuples."" 2022-02-11 01:32:45 -08:00
Mishal Shah
dcd9e8e84e Revert "[Regex] Switch regex match to Swift tuples." 2022-02-10 15:21:53 -08:00
Richard Wei
cf8e0fea12 [Regex] Switch regex match to Swift tuples.
Typed captures no longer use ad-hoc nominal tuples. We use Swift native tuples instead. See apple/swift-experimental-string-processing#127.

Update checkout tag to dev/6.
2022-02-09 16:21:57 -08:00
Erik Eckstein
3d33f11e6c cmake/build-script: rename the libswift option to "bootstrapping"
In cmake, rename LIBSWIFT_BUILD_MODE to BOOTSTRAPPING_MODE.
Also, rename the lit feature "libswift" to "swift_in_compiler".
2021-12-22 11:31:52 +01:00
Michael Ilseman
7bff9da67d Revert "Revert "Merge pull request #40595 from hamishknight/straw-bales"" 2021-12-19 10:08:48 -07:00
Arnold Schwaighofer
9511994e52 Revert "Merge pull request #40595 from hamishknight/straw-bales"
This reverts commit a67a0436f7, reversing
changes made to 9965df76d0.

This commit or the earlier commit this commit is based on (#40531) broke the
incremental bot.
2021-12-18 11:02:37 -08:00
Hamish Knight
128f5d4bc6 Update regex literal lexing and emission
Update the lexing implementation to defer to the
regex library, which will pass back the pointer
from to resume lexing, and update the emission to
call the new `Regex(_regexString:version:)`
overload, that will accept the regex string with
delimiters.

Because this uses the library's lexing
implementation, the delimiters are now `'/.../'`
and `'|...|'` instead of plain `'...'`.
2021-12-17 18:05:31 +00:00
Richard Wei
300cbaba31 Integrate experimental string processing modules and enable end-to-end regex.
- Checkout apple/swift-experimental-string-processing using a tag.
- Build `_MatchingEngine` as part of libswift (`ExperimentalRegex`) using sources from the package.
- Parse regex literals using the parser from `_MatchingEngine`.
- Build both `_MatchingEngine` and `_StringProcessing` as part of core libs using sources from the package.
- Use `Regex<DynamicCaptures>` as the default regex type until we finalize apple/swift-experimental-string-processing#68.
2021-12-17 10:33:07 +00:00
Richard Wei
05363cd55a Regex literal runtime plumbing.
- Frontend: Implicitly import `_StringProcessing` when frontend flag `-enable-experimental-string-processing` is set.
- Type checker: Set a regex literal expression's type as `_StringProcessing.Regex<(Substring, DynamicCaptures)>`. `(Substring, DynamicCaptures)` is a temporary `Match` type that will help get us to an end-to-end working system. This will be replaced by actual type inference based a regex's pattern in a follow-up patch (soon).
- SILGen: Lower a regex literal expression to a call to `_StringProcessing.Regex.init(_regexString:)`.
- String processing runtime: Add `Regex`, `DynamicCaptures` (matching actual APIs in apple/swift-experimental-string-processing), and `Regex(_regexString:)`.

Upcoming:
- Build `_MatchingEngine` and `_StringProcessing` modules with sources from apple/swift-experimental-string-processing.
- Replace `DynamicCaptures` with inferred capture types.
2021-12-09 16:05:34 -08:00