File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
Sources/_MatchingEngine/Regex/Parse Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -420,25 +420,30 @@ extension Source {
420
420
/// delimiter. If `ignoreEscaped` is true, escaped characters will not be
421
421
/// considered for the ending delimiter.
422
422
private mutating func expectQuoted(
423
- endingWith end: String , ignoreEscaped: Bool = false
423
+ endingWith end: String , ignoreEscaped: Bool = false , eatEnding : Bool = true
424
424
) throws -> Located < String > {
425
- try recordLoc { src in
426
- let result = try src. lexUntil { src in
427
- if try src. tryEatNonEmpty ( sequence : end) {
425
+ let result = try recordLoc { src -> String in
426
+ try src. lexUntil { src in
427
+ if src. starts ( with : end) {
428
428
return true
429
429
}
430
+ try src. expectNonEmpty ( . expected( end) )
431
+
430
432
// Ignore escapes if we're allowed to. lexUntil will consume the next
431
433
// character.
432
434
if ignoreEscaped, src. tryEat ( " \\ " ) {
433
435
try src. expectNonEmpty ( . expectedEscape)
434
436
}
435
437
return false
436
438
} . value
437
- guard !result. isEmpty else {
438
- throw ParseError . expectedNonEmptyContents
439
- }
440
- return result
441
439
}
440
+ guard !result. value. isEmpty else {
441
+ throw ParseError . expectedNonEmptyContents
442
+ }
443
+ if eatEnding {
444
+ try expect ( sequence: end)
445
+ }
446
+ return result
442
447
}
443
448
444
449
/// Try to consume quoted content
You can’t perform that action at this time.
0 commit comments