@@ -493,7 +493,7 @@ struct CharacterByte: ExpressibleByUnicodeScalarLiteral, ExpressibleByIntegerLit
493
493
let value : UInt8
494
494
495
495
init ( unicodeScalarLiteral value: Unicode . Scalar ) {
496
- self . value = UInt8 ( ascii: Unicode . Scalar ( unicodeScalarLiteral : value) )
496
+ self . value = UInt8 ( ascii: value)
497
497
}
498
498
499
499
init ( integerLiteral value: UInt8 ) {
@@ -964,11 +964,11 @@ extension Lexer.Cursor {
964
964
return Lexer . Result ( . endOfFile)
965
965
default :
966
966
var tmp = self
967
- if tmp. advance ( if: { Unicode . Scalar ( $0 ) . isValidIdentifierStartCodePoint } ) {
967
+ if tmp. advance ( if: { $0 . isValidIdentifierStartCodePoint } ) {
968
968
return self . lexIdentifier ( )
969
969
}
970
970
971
- if tmp. advance ( if: { Unicode . Scalar ( $0 ) . isOperatorStartCodePoint } ) {
971
+ if tmp. advance ( if: { $0 . isOperatorStartCodePoint } ) {
972
972
return self . lexOperatorIdentifier (
973
973
sourceBufferStart: sourceBufferStart,
974
974
preferRegexOverBinaryOperator: preferRegexOverBinaryOperator
@@ -1009,7 +1009,7 @@ extension Lexer.Cursor {
1009
1009
private mutating func lexAfterClosingStringQuote( ) -> Lexer . Result {
1010
1010
switch self . peek ( ) {
1011
1011
case " # " :
1012
- self . advance ( while: { $0 == Unicode . Scalar ( " # " ) } )
1012
+ self . advance ( while: { $0 == " # " } )
1013
1013
return Lexer . Result ( . rawStringPoundDelimiter, stateTransition: . pop)
1014
1014
case nil :
1015
1015
return Lexer . Result ( . endOfFile)
@@ -1028,7 +1028,7 @@ extension Lexer.Cursor {
1028
1028
/// number of '#' is correct because otherwise `isAtStringInterpolationAnchor`
1029
1029
/// would have returned false in `lexInStringLiteral` and w we wouldn't have
1030
1030
/// transitioned to the `afterBackslashOfStringInterpolation` state.
1031
- self . advance ( while: { $0 == Unicode . Scalar ( " # " ) } )
1031
+ self . advance ( while: { $0 == " # " } )
1032
1032
return Lexer . Result ( . rawStringPoundDelimiter)
1033
1033
case " ( " :
1034
1034
_ = self . advance ( )
@@ -1248,9 +1248,7 @@ extension Lexer.Cursor {
1248
1248
)
1249
1249
}
1250
1250
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 == " _ " } )
1254
1252
1255
1253
let tmp = self
1256
1254
if self . advance ( if: { $0. isValidIdentifierContinuationCodePoint } ) {
@@ -1279,9 +1277,7 @@ extension Lexer.Cursor {
1279
1277
)
1280
1278
}
1281
1279
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 == " _ " } )
1285
1281
1286
1282
let tmp = self
1287
1283
if self . advance ( if: { $0. isValidIdentifierContinuationCodePoint } ) {
@@ -1298,7 +1294,7 @@ extension Lexer.Cursor {
1298
1294
1299
1295
// Handle a leading [0-9]+, lexing an integer or falling through if we have a
1300
1296
// floating point value.
1301
- self . advance ( while: { $0. isDigit || $0 == Unicode . Scalar ( " _ " ) } )
1297
+ self . advance ( while: { $0. isDigit || $0 == " _ " } )
1302
1298
1303
1299
// TODO: This can probably be unified with lexHexNumber somehow
1304
1300
@@ -1333,7 +1329,7 @@ extension Lexer.Cursor {
1333
1329
// Lex decimal point.
1334
1330
if self . advance ( matching: " . " ) {
1335
1331
// Lex any digits after the decimal point.
1336
- self . advance ( while: { $0. isDigit || $0 == Unicode . Scalar ( " _ " ) } )
1332
+ self . advance ( while: { $0. isDigit || $0 == " _ " } )
1337
1333
}
1338
1334
1339
1335
// Lex exponent.
@@ -1364,7 +1360,7 @@ extension Lexer.Cursor {
1364
1360
)
1365
1361
}
1366
1362
1367
- self . advance ( while: { $0. isDigit || $0 == Unicode . Scalar ( " _ " ) } )
1363
+ self . advance ( while: { $0. isDigit || $0 == " _ " } )
1368
1364
1369
1365
let tmp = self
1370
1366
if self . advance ( if: { $0. isValidIdentifierContinuationCodePoint } ) {
@@ -1401,7 +1397,7 @@ extension Lexer.Cursor {
1401
1397
}
1402
1398
}
1403
1399
1404
- self . advance ( while: { $0. isHexDigit || $0 == Unicode . Scalar ( " _ " ) } )
1400
+ self . advance ( while: { $0. isHexDigit || $0 == " _ " } )
1405
1401
1406
1402
if self . isAtEndOfFile || self . is ( notAt: " . " , " p " , " P " ) {
1407
1403
let tmp = self
@@ -1429,7 +1425,7 @@ extension Lexer.Cursor {
1429
1425
return Lexer . Result ( . integerLiteral)
1430
1426
}
1431
1427
1432
- self . advance ( while: { $0. isHexDigit || $0 == Unicode . Scalar ( " _ " ) } )
1428
+ self . advance ( while: { $0. isHexDigit || $0 == " _ " } )
1433
1429
1434
1430
if self . isAtEndOfFile || self . is ( notAt: " p " , " P " ) {
1435
1431
if let peeked = self . peek ( at: 1 ) , !Unicode. Scalar ( peeked) . isDigit {
@@ -1486,7 +1482,7 @@ extension Lexer.Cursor {
1486
1482
)
1487
1483
}
1488
1484
1489
- self . advance ( while: { $0. isDigit || $0 == Unicode . Scalar ( " _ " ) } )
1485
+ self . advance ( while: { $0. isDigit || $0 == " _ " } )
1490
1486
1491
1487
let tmp = self
1492
1488
if self . advance ( if: { $0. isValidIdentifierContinuationCodePoint } ) {
@@ -1605,7 +1601,7 @@ extension Lexer.Cursor {
1605
1601
case " \\ " : // Escapes.
1606
1602
_ = self . advance ( )
1607
1603
if !self . advanceIfStringDelimiter ( delimiterLength: delimiterLength) {
1608
- return . success( Unicode . Scalar ( " \\ " ) )
1604
+ return . success( " \\ " )
1609
1605
}
1610
1606
switch self . lexEscapedCharacter ( isMultilineString: stringLiteralKind == . multiLine) {
1611
1607
case . success( let codePoint) :
@@ -1720,7 +1716,7 @@ extension Lexer.Cursor {
1720
1716
case " " , " \t " :
1721
1717
continue
1722
1718
case " \r " :
1723
- _ = tmp. advance ( if: { $0 == Unicode . Scalar ( " \n " ) } )
1719
+ _ = tmp. advance ( if: { $0 == " \n " } )
1724
1720
fallthrough
1725
1721
case " \n " :
1726
1722
self = tmp
@@ -1777,7 +1773,7 @@ extension Lexer.Cursor {
1777
1773
// Scan ahead until the end of the line. Every time we see a closing
1778
1774
// quote, check if it is followed by the correct number of closing delimiters.
1779
1775
while isSingleLineString. is ( notAt: " \r " , " \n " ) {
1780
- if isSingleLineString. advance ( if: { $0 == Unicode . Scalar ( ( #"""# ) ) } ) {
1776
+ if isSingleLineString. advance ( if: { $0 == #"""# } ) {
1781
1777
if isSingleLineString. advanceIfStringDelimiter ( delimiterLength: leadingDelimiterLength) {
1782
1778
return Lexer . Result ( . stringQuote, stateTransition: stateTransitionAfterLexingStringQuote ( kind: . singleLine) )
1783
1779
}
@@ -2239,7 +2235,7 @@ extension Lexer.Cursor {
2239
2235
case . error:
2240
2236
// If the character was incorrectly encoded, give up.
2241
2237
return nil
2242
- case . endOfString, . success( Unicode . Scalar ( 0x201D ) ) :
2238
+ case . endOfString, . success( " \u{201D} " ) :
2243
2239
// If we found a closing quote, then we're done. Just return the spot
2244
2240
// to continue.
2245
2241
return body
@@ -2263,10 +2259,10 @@ extension Lexer.Cursor {
2263
2259
precondition ( !( self . peekScalar ( ) ? . isValidIdentifierStartCodePoint ?? false ) && !( self . peekScalar ( ) ? . isOperatorStartCodePoint ?? false ) )
2264
2260
let start = self
2265
2261
var tmp = self
2266
- if tmp. advance ( if: { Unicode . Scalar ( $0 ) . isValidIdentifierContinuationCodePoint } ) {
2262
+ if tmp. advance ( if: { $0 . isValidIdentifierContinuationCodePoint } ) {
2267
2263
// If this is a valid identifier continuation, but not a valid identifier
2268
2264
// start, attempt to recover by eating more continuation characters.
2269
- tmp. advance ( while: { Unicode . Scalar ( $0 ) . isValidIdentifierContinuationCodePoint } )
2265
+ tmp. advance ( while: { $0 . isValidIdentifierContinuationCodePoint } )
2270
2266
self = tmp
2271
2267
return . lexemeContents( Lexer . Result ( . identifier, error: LexingDiagnostic ( . invalidIdentifierStartCharacter, position: start) ) )
2272
2268
}
@@ -2370,10 +2366,8 @@ extension Lexer.Cursor {
2370
2366
previous: curPtr. input [ markerKind. introducer. utf8. count - 1 ]
2371
2367
)
2372
2368
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 } )
2377
2371
2378
2372
guard restOfBuffer. starts ( with: markerKind. terminator. utf8) else {
2379
2373
_ = restOfBuffer. advance ( )
0 commit comments