Skip to content

Commit ed08886

Browse files
committed
Remove throws from a couple of lexing methods
1 parent 13b361c commit ed08886

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

Sources/_RegexParser/Regex/Parse/LexicalAnalysis.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,7 @@ extension Source {
421421
) throws -> (Located<Quant.Amount>, Located<Quant.Kind>, [AST.Trivia])? {
422422
var trivia: [AST.Trivia] = []
423423

424-
if let t = try lexNonSemanticWhitespace(context: context) {
425-
trivia.append(t)
426-
}
424+
if let t = lexNonSemanticWhitespace(context: context) { trivia.append(t) }
427425

428426
let amt: Located<Quant.Amount>? = try recordLoc { src in
429427
if src.tryEat("*") { return .zeroOrMore }
@@ -441,9 +439,7 @@ extension Source {
441439
guard let amt = amt else { return nil }
442440

443441
// PCRE allows non-semantic whitespace here in extended syntax mode.
444-
if let t = try lexNonSemanticWhitespace(context: context) {
445-
trivia.append(t)
446-
}
442+
if let t = lexNonSemanticWhitespace(context: context) { trivia.append(t) }
447443

448444
let kind: Located<Quant.Kind> = recordLoc { src in
449445
if src.tryEat("?") { return .reluctant }
@@ -675,7 +671,7 @@ extension Source {
675671
/// Does nothing unless `SyntaxOptions.nonSemanticWhitespace` is set
676672
mutating func lexNonSemanticWhitespace(
677673
context: ParsingContext
678-
) throws -> AST.Trivia? {
674+
) -> AST.Trivia? {
679675
guard context.ignoreWhitespace else { return nil }
680676

681677
// FIXME: PCRE only treats space and tab characters as whitespace when
@@ -707,7 +703,7 @@ extension Source {
707703
if let comment = try lexComment(context: context) {
708704
return comment
709705
}
710-
if let whitespace = try lexNonSemanticWhitespace(context: context) {
706+
if let whitespace = lexNonSemanticWhitespace(context: context) {
711707
return whitespace
712708
}
713709
return nil
@@ -1186,8 +1182,7 @@ extension Source {
11861182
}
11871183
}
11881184

1189-
mutating func lexCustomCCStart(
1190-
) throws -> Located<CustomCC.Start>? {
1185+
mutating func lexCustomCCStart() -> Located<CustomCC.Start>? {
11911186
recordLoc { src in
11921187
// Make sure we don't have a POSIX character property. This may require
11931188
// walking to its ending to make sure we have a closing ':]', as otherwise

Sources/_RegexParser/Regex/Parse/Parse.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ extension Parser {
429429
}
430430

431431
// Check if we have the start of a custom character class '['.
432-
if let cccStart = try source.lexCustomCCStart() {
432+
if let cccStart = source.lexCustomCCStart() {
433433
return .customCharacterClass(
434434
try parseCustomCharacterClass(cccStart))
435435
}
@@ -513,7 +513,7 @@ extension Parser {
513513
source.peekCCBinOp() == nil {
514514

515515
// Nested custom character class.
516-
if let cccStart = try source.lexCustomCCStart() {
516+
if let cccStart = source.lexCustomCCStart() {
517517
members.append(.custom(try parseCustomCharacterClass(cccStart)))
518518
continue
519519
}
@@ -527,7 +527,7 @@ extension Parser {
527527
// Lex non-semantic whitespace if we're allowed.
528528
// TODO: ICU allows end-of-line comments in custom character classes,
529529
// which we ought to support if we want to support multi-line regex.
530-
if let trivia = try source.lexNonSemanticWhitespace(context: context) {
530+
if let trivia = source.lexNonSemanticWhitespace(context: context) {
531531
members.append(.trivia(trivia))
532532
continue
533533
}

0 commit comments

Comments
 (0)