@@ -493,7 +493,7 @@ struct CharacterByte: ExpressibleByUnicodeScalarLiteral, ExpressibleByIntegerLit
493493 let value : UInt8
494494
495495 init ( unicodeScalarLiteral value: Unicode . Scalar ) {
496- self . value = UInt8 ( ascii: Unicode . Scalar ( unicodeScalarLiteral : value) )
496+ self . value = UInt8 ( ascii: value)
497497 }
498498
499499 init ( integerLiteral value: UInt8 ) {
@@ -964,11 +964,11 @@ extension Lexer.Cursor {
964964 return Lexer . Result ( . endOfFile)
965965 default :
966966 var tmp = self
967- if tmp. advance ( if: { Unicode . Scalar ( $0 ) . isValidIdentifierStartCodePoint } ) {
967+ if tmp. advance ( if: { $0 . isValidIdentifierStartCodePoint } ) {
968968 return self . lexIdentifier ( )
969969 }
970970
971- if tmp. advance ( if: { Unicode . Scalar ( $0 ) . isOperatorStartCodePoint } ) {
971+ if tmp. advance ( if: { $0 . isOperatorStartCodePoint } ) {
972972 return self . lexOperatorIdentifier (
973973 sourceBufferStart: sourceBufferStart,
974974 preferRegexOverBinaryOperator: preferRegexOverBinaryOperator
@@ -1009,7 +1009,7 @@ extension Lexer.Cursor {
10091009 private mutating func lexAfterClosingStringQuote( ) -> Lexer . Result {
10101010 switch self . peek ( ) {
10111011 case " # " :
1012- self . advance ( while: { $0 == Unicode . Scalar ( " # " ) } )
1012+ self . advance ( while: { $0 == " # " } )
10131013 return Lexer . Result ( . rawStringPoundDelimiter, stateTransition: . pop)
10141014 case nil :
10151015 return Lexer . Result ( . endOfFile)
@@ -1028,7 +1028,7 @@ extension Lexer.Cursor {
10281028 /// number of '#' is correct because otherwise `isAtStringInterpolationAnchor`
10291029 /// would have returned false in `lexInStringLiteral` and w we wouldn't have
10301030 /// transitioned to the `afterBackslashOfStringInterpolation` state.
1031- self . advance ( while: { $0 == Unicode . Scalar ( " # " ) } )
1031+ self . advance ( while: { $0 == " # " } )
10321032 return Lexer . Result ( . rawStringPoundDelimiter)
10331033 case " ( " :
10341034 _ = self . advance ( )
@@ -1248,9 +1248,7 @@ extension Lexer.Cursor {
12481248 )
12491249 }
12501250
1251- self . advance ( while: {
1252- ( $0 >= Unicode . Scalar ( " 0 " ) && $0 <= Unicode . Scalar ( " 7 " ) ) || $0 == Unicode . Scalar ( " _ " )
1253- } )
1251+ self . advance ( while: { ( $0 >= " 0 " && $0 <= " 7 " ) || $0 == " _ " } )
12541252
12551253 let tmp = self
12561254 if self . advance ( if: { $0. isValidIdentifierContinuationCodePoint } ) {
@@ -1279,9 +1277,7 @@ extension Lexer.Cursor {
12791277 )
12801278 }
12811279
1282- self . advance ( while: {
1283- $0 == Unicode . Scalar ( " 0 " ) || $0 == Unicode . Scalar ( " 1 " ) || $0 == Unicode . Scalar ( " _ " )
1284- } )
1280+ self . advance ( while: { $0 == " 0 " || $0 == " 1 " || $0 == " _ " } )
12851281
12861282 let tmp = self
12871283 if self . advance ( if: { $0. isValidIdentifierContinuationCodePoint } ) {
@@ -1298,7 +1294,7 @@ extension Lexer.Cursor {
12981294
12991295 // Handle a leading [0-9]+, lexing an integer or falling through if we have a
13001296 // floating point value.
1301- self . advance ( while: { $0. isDigit || $0 == Unicode . Scalar ( " _ " ) } )
1297+ self . advance ( while: { $0. isDigit || $0 == " _ " } )
13021298
13031299 // TODO: This can probably be unified with lexHexNumber somehow
13041300
@@ -1333,7 +1329,7 @@ extension Lexer.Cursor {
13331329 // Lex decimal point.
13341330 if self . advance ( matching: " . " ) {
13351331 // Lex any digits after the decimal point.
1336- self . advance ( while: { $0. isDigit || $0 == Unicode . Scalar ( " _ " ) } )
1332+ self . advance ( while: { $0. isDigit || $0 == " _ " } )
13371333 }
13381334
13391335 // Lex exponent.
@@ -1364,7 +1360,7 @@ extension Lexer.Cursor {
13641360 )
13651361 }
13661362
1367- self . advance ( while: { $0. isDigit || $0 == Unicode . Scalar ( " _ " ) } )
1363+ self . advance ( while: { $0. isDigit || $0 == " _ " } )
13681364
13691365 let tmp = self
13701366 if self . advance ( if: { $0. isValidIdentifierContinuationCodePoint } ) {
@@ -1401,7 +1397,7 @@ extension Lexer.Cursor {
14011397 }
14021398 }
14031399
1404- self . advance ( while: { $0. isHexDigit || $0 == Unicode . Scalar ( " _ " ) } )
1400+ self . advance ( while: { $0. isHexDigit || $0 == " _ " } )
14051401
14061402 if self . isAtEndOfFile || self . is ( notAt: " . " , " p " , " P " ) {
14071403 let tmp = self
@@ -1429,7 +1425,7 @@ extension Lexer.Cursor {
14291425 return Lexer . Result ( . integerLiteral)
14301426 }
14311427
1432- self . advance ( while: { $0. isHexDigit || $0 == Unicode . Scalar ( " _ " ) } )
1428+ self . advance ( while: { $0. isHexDigit || $0 == " _ " } )
14331429
14341430 if self . isAtEndOfFile || self . is ( notAt: " p " , " P " ) {
14351431 if let peeked = self . peek ( at: 1 ) , !Unicode. Scalar ( peeked) . isDigit {
@@ -1486,7 +1482,7 @@ extension Lexer.Cursor {
14861482 )
14871483 }
14881484
1489- self . advance ( while: { $0. isDigit || $0 == Unicode . Scalar ( " _ " ) } )
1485+ self . advance ( while: { $0. isDigit || $0 == " _ " } )
14901486
14911487 let tmp = self
14921488 if self . advance ( if: { $0. isValidIdentifierContinuationCodePoint } ) {
@@ -1605,7 +1601,7 @@ extension Lexer.Cursor {
16051601 case " \\ " : // Escapes.
16061602 _ = self . advance ( )
16071603 if !self . advanceIfStringDelimiter ( delimiterLength: delimiterLength) {
1608- return . success( Unicode . Scalar ( " \\ " ) )
1604+ return . success( " \\ " )
16091605 }
16101606 switch self . lexEscapedCharacter ( isMultilineString: stringLiteralKind == . multiLine) {
16111607 case . success( let codePoint) :
@@ -1720,7 +1716,7 @@ extension Lexer.Cursor {
17201716 case " " , " \t " :
17211717 continue
17221718 case " \r " :
1723- _ = tmp. advance ( if: { $0 == Unicode . Scalar ( " \n " ) } )
1719+ _ = tmp. advance ( if: { $0 == " \n " } )
17241720 fallthrough
17251721 case " \n " :
17261722 self = tmp
@@ -1777,7 +1773,7 @@ extension Lexer.Cursor {
17771773 // Scan ahead until the end of the line. Every time we see a closing
17781774 // quote, check if it is followed by the correct number of closing delimiters.
17791775 while isSingleLineString. is ( notAt: " \r " , " \n " ) {
1780- if isSingleLineString. advance ( if: { $0 == Unicode . Scalar ( ( #"""# ) ) } ) {
1776+ if isSingleLineString. advance ( if: { $0 == #"""# } ) {
17811777 if isSingleLineString. advanceIfStringDelimiter ( delimiterLength: leadingDelimiterLength) {
17821778 return Lexer . Result ( . stringQuote, stateTransition: stateTransitionAfterLexingStringQuote ( kind: . singleLine) )
17831779 }
@@ -2239,7 +2235,7 @@ extension Lexer.Cursor {
22392235 case . error:
22402236 // If the character was incorrectly encoded, give up.
22412237 return nil
2242- case . endOfString, . success( Unicode . Scalar ( 0x201D ) ) :
2238+ case . endOfString, . success( " \u{201D} " ) :
22432239 // If we found a closing quote, then we're done. Just return the spot
22442240 // to continue.
22452241 return body
@@ -2263,10 +2259,10 @@ extension Lexer.Cursor {
22632259 precondition ( !( self . peekScalar ( ) ? . isValidIdentifierStartCodePoint ?? false ) && !( self . peekScalar ( ) ? . isOperatorStartCodePoint ?? false ) )
22642260 let start = self
22652261 var tmp = self
2266- if tmp. advance ( if: { Unicode . Scalar ( $0 ) . isValidIdentifierContinuationCodePoint } ) {
2262+ if tmp. advance ( if: { $0 . isValidIdentifierContinuationCodePoint } ) {
22672263 // If this is a valid identifier continuation, but not a valid identifier
22682264 // start, attempt to recover by eating more continuation characters.
2269- tmp. advance ( while: { Unicode . Scalar ( $0 ) . isValidIdentifierContinuationCodePoint } )
2265+ tmp. advance ( while: { $0 . isValidIdentifierContinuationCodePoint } )
22702266 self = tmp
22712267 return . lexemeContents( Lexer . Result ( . identifier, error: LexingDiagnostic ( . invalidIdentifierStartCharacter, position: start) ) )
22722268 }
@@ -2370,10 +2366,8 @@ extension Lexer.Cursor {
23702366 previous: curPtr. input [ markerKind. introducer. utf8. count - 1 ]
23712367 )
23722368 while !restOfBuffer. isAtEndOfFile {
2373- let terminatorStart = markerKind. terminator. utf8. first!
2374- restOfBuffer. advance ( while: { byte in
2375- byte != Unicode . Scalar ( terminatorStart)
2376- } )
2369+ let terminatorStart = markerKind. terminator. unicodeScalars. first!
2370+ restOfBuffer. advance ( while: { byte in byte != terminatorStart } )
23772371
23782372 guard restOfBuffer. starts ( with: markerKind. terminator. utf8) else {
23792373 _ = restOfBuffer. advance ( )
0 commit comments