Skip to content

Commit acd3d1c

Browse files
committed
Simplify character class parsing a little
We don't have to handle bailing early, the loop will terminate if we don't lex another operator.
1 parent 2227777 commit acd3d1c

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

Sources/_RegexParser/Regex/Parse/Parse.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,7 @@ extension Parser {
485485
throw Source.LocatedError(
486486
ParseError.expectedCustomCharacterClassMembers, start.location)
487487
}
488-
489-
// If we're done, bail early
490-
let setOp = Member.setOperation(members, binOp, rhs)
491-
if source.tryEat("]") {
492-
return CustomCC(
493-
start, [setOp], loc(start.location.start))
494-
}
495-
496-
// Otherwise it's just another member to accumulate
497-
members = [setOp]
488+
members = [.setOperation(members, binOp, rhs)]
498489
}
499490
if members.none(\.isSemantic) {
500491
throw Source.LocatedError(

0 commit comments

Comments
 (0)