@@ -18,10 +18,11 @@ extension Character {
18
18
self . rawValue = rawValue
19
19
}
20
20
21
- static let IDENT_CONT : Self = . init( rawValue: 0x01 )
22
- static let DECIMAL : Self = . init( rawValue: 0x02 )
23
- static let HEX : Self = . init( rawValue: 0x04 )
24
- static let LETTER : Self = . init( rawValue: 0x08 )
21
+ static let IDENT_START : Self = . init( rawValue: 0x01 )
22
+ static let IDENT_CONT : Self = . init( rawValue: 0x02 )
23
+ static let DECIMAL : Self = . init( rawValue: 0x04 )
24
+ static let HEX : Self = . init( rawValue: 0x08 )
25
+ static let LETTER : Self = . init( rawValue: 0x10 )
25
26
}
26
27
}
27
28
@@ -34,7 +35,7 @@ extension Unicode.Scalar {
34
35
/// to be allowed to appear in a starting position in a programming language
35
36
/// identifier.
36
37
var isAsciiIdentifierStart : Bool {
37
- self . testCharacterInfo ( . IDENT_CONT ) && ! self . isDigit && self != " $ "
38
+ self . testCharacterInfo ( . IDENT_START )
38
39
}
39
40
40
41
/// A Boolean value indicating whether this scalar is one which is recommended
@@ -69,11 +70,6 @@ extension Unicode.Scalar {
69
70
) -> Bool {
70
71
let info : Character . Info
71
72
switch self . value {
72
- case
73
- // '$', '_'
74
- 36 , 95 :
75
- info = [ . IDENT_CONT]
76
-
77
73
case
78
74
// '0'-'9'
79
75
48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 :
@@ -84,7 +80,7 @@ extension Unicode.Scalar {
84
80
65 , 66 , 67 , 68 , 69 , 70 ,
85
81
// 'a'-'f'
86
82
97 , 98 , 99 , 100 , 101 , 102 :
87
- info = [ . IDENT_CONT, . HEX, . LETTER]
83
+ info = [ . IDENT_START , . IDENT_CONT, . HEX, . LETTER]
88
84
89
85
case
90
86
// 'G'-'Z'
@@ -93,7 +89,17 @@ extension Unicode.Scalar {
93
89
// 'g'-'z'
94
90
103 , 104 , 105 , 106 , 107 , 108 , 109 , 110 , 111 , 112 , 113 , 114 , 115 , 116 , 117 ,
95
91
118 , 119 , 120 , 121 , 122 :
96
- info = [ . IDENT_CONT, . LETTER]
92
+ info = [ . IDENT_START, . IDENT_CONT, . LETTER]
93
+
94
+ case
95
+ // '_'
96
+ 95 :
97
+ info = [ . IDENT_START, . IDENT_CONT]
98
+
99
+ case
100
+ // '$'
101
+ 36 :
102
+ info = [ . IDENT_CONT]
97
103
98
104
default :
99
105
info = [ ]
0 commit comments