Skip to content

Commit addfbfd

Browse files
committed
Update pitch
1 parent f4ef0c2 commit addfbfd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Documentation/Evolution/DelimiterSyntax.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func matchHexAssignment(_ input: String) -> (String, Int)? {
8080
}
8181
```
8282

83-
Unnamed capture groups produce unlabeled tuple elements and must be referenced by their position, e.g `match.1`, `match.2`.
83+
Unnamed capture groups produce unlabeled tuple elements and must be referenced by their position, e.g `match.1`, `match.2`. See [StronglyTypedCaptures.md](https://github.com/apple/swift-experimental-string-processing/blob/main/Documentation/Evolution/StronglyTypedCaptures.md) for more info.
8484

8585
**TODO: Should we cover more general typed capture behavior from [StronglyTypedCaptures.md](https://github.com/apple/swift-experimental-string-processing/blob/main/Documentation/Evolution/StronglyTypedCaptures.md) here? There is some overlap with the typed capture behavior of the DSL tho, labels are the main thing that are literal specific**
8686

@@ -156,7 +156,7 @@ Perhaps the most obvious parsing ambiguity with `/.../` delimiters is with comme
156156

157157
### Ambiguity with infix operators
158158

159-
There would be a minor ambiguity with infix operators used with regex literals. When used without whitespace, e.g `x+/y/`, the expression will be treated as using an infix operator `+/`. Whitespace is therefore required `x + /y/` for regex literal interpretation. Alternatively, extended syntax may be used, e.g `x+#/y/#`.
159+
There would be a minor ambiguity with infix operators used with regex literals. When used without whitespace, e.g `x+/y/`, the expression will be treated as using an infix operator `+/`. Whitespace is therefore required for regex literal interpretation, e.g `x + /y/`. Alternatively, extended syntax may be used, e.g `x+#/y/#`.
160160

161161
### Regex syntax limitations
162162

@@ -241,8 +241,6 @@ Postfix `/` operators do not require banning, as they'd only be treated as regex
241241

242242
#### `/,` and `/]` as regex literal openings
243243

244-
**TODO: Do we still want to break source here given we're also proposing `#/.../#`?**
245-
246244
As stated previously, there is a parsing ambiguity with unapplied operators in argument lists, tuples, and parentheses. Some of these cases can be mitigated by not parsing a regex literal if the starting character is `)`. However it does not solve the issue when the next character is `,` or `]`. Both of these are valid regex starting characters, and comma in particular may be a fairly common case for a regex.
247245

248246
For example:
@@ -284,7 +282,9 @@ This takes advantage of the fact that a regex literal will not be parsed if the
284282

285283
## Future Directions
286284

287-
**TODO: Do we have any other future directions now that extended multi-line syntax has been subsumed?**
285+
### Modern literal syntax
286+
287+
We could support a more modern Swift-like syntax in regex literals. For example, comments could be done with `//` and `/* ... */`, and quoted sequences could be done with `"..."`. This would however be incompatible with the syntactic superset of regex syntax we intend to parse, and as such may need to be introduced using a new literal kind, with no obvious choice of delimiter. However, it's possible that the ability to use regex literals in the DSL lessens the benefit that this syntax would bring.
288288

289289
## Alternatives Considered
290290

0 commit comments

Comments
 (0)