@@ -44,11 +44,6 @@ public class Trivia {
44
44
/// Useful for multi-character trivias like `\r\n`.
45
45
public let characters : [ Character ]
46
46
47
- /// The list of characters as they would appear in Swift code.
48
- ///
49
- /// This might differ from `characters` due to Swift's character escape requirements.
50
- public let swiftCharacters : [ Character ]
51
-
52
47
/// The traits.
53
48
public let traits : TriviaTraits
54
49
@@ -84,40 +79,25 @@ public class Trivia {
84
79
/// - name: A name of the trivia.
85
80
/// - comment: A doc comment describing the trivia.
86
81
/// - characters: A list of characters that make up the trivia.
87
- /// - swiftCharacters: A list of characters as they would appear in Swift code.
88
82
/// - isComment: Indicates if the trivia represents a comment.
89
83
init (
90
84
name: TokenSyntax ,
91
85
comment: SwiftSyntax . Trivia ,
92
86
characters: [ Character ] = [ ] ,
93
- swiftCharacters: [ Character ] = [ ] ,
94
87
traits: TriviaTraits = [ ]
95
88
) {
96
89
self . name = name
97
90
self . comment = comment
98
91
self . characters = characters
99
92
self . traits = traits
100
-
101
- // Swift sometimes doesn't support escaped characters like \f or \v;
102
- // we should allow specifying alternatives explicitly.
103
- if !swiftCharacters. isEmpty {
104
- self . swiftCharacters = swiftCharacters
105
- } else {
106
- self . swiftCharacters = characters
107
- }
108
93
}
109
94
}
110
95
111
96
public let TRIVIAS : [ Trivia ] = [
112
97
Trivia (
113
98
name: " Backslash " ,
114
99
comment: #"A backslash that is at the end of a line in a multi-line string literal to escape the newline."# ,
115
- characters: [
116
- Character ( " \\ " )
117
- ] ,
118
- swiftCharacters: [
119
- Character ( " \\ " )
120
- ]
100
+ characters: [ " \\ " ]
121
101
) ,
122
102
123
103
Trivia (
@@ -129,26 +109,14 @@ public let TRIVIAS: [Trivia] = [
129
109
Trivia (
130
110
name: " CarriageReturn " ,
131
111
comment: #"A newline '\r' character."# ,
132
- characters: [
133
- Character ( " \r " )
134
- ] ,
135
- swiftCharacters: [
136
- Character ( " \r " )
137
- ] ,
112
+ characters: [ " \r " ] ,
138
113
traits: [ . whitespace, . newline]
139
114
) ,
140
115
141
116
Trivia (
142
117
name: " CarriageReturnLineFeed " ,
143
118
comment: #"A newline consists of contiguous '\r' and '\n' characters."# ,
144
- characters: [
145
- Character ( " \r " ) ,
146
- Character ( " \n " ) ,
147
- ] ,
148
- swiftCharacters: [
149
- Character ( " \r " ) ,
150
- Character ( " \n " ) ,
151
- ] ,
119
+ characters: [ " \r " , " \n " ] ,
152
120
traits: [ . whitespace, . newline]
153
121
) ,
154
122
@@ -168,12 +136,7 @@ public let TRIVIAS: [Trivia] = [
168
136
Trivia (
169
137
name: " Formfeed " ,
170
138
comment: #"A form-feed 'f' character."# ,
171
- characters: [
172
- Character ( " \u{c} " )
173
- ] ,
174
- swiftCharacters: [
175
- Character ( " \u{240C} " )
176
- ] ,
139
+ characters: [ " \u{000C} " ] ,
177
140
traits: [ . whitespace]
178
141
) ,
179
142
@@ -186,47 +149,27 @@ public let TRIVIAS: [Trivia] = [
186
149
Trivia (
187
150
name: " Newline " ,
188
151
comment: #"A newline '\n' character."# ,
189
- characters: [
190
- Character ( " \n " )
191
- ] ,
192
- swiftCharacters: [
193
- Character ( " \n " )
194
- ] ,
152
+ characters: [ " \n " ] ,
195
153
traits: [ . whitespace, . newline]
196
154
) ,
197
155
198
156
Trivia (
199
157
name: " Pound " ,
200
158
comment: #"A '#' that is at the end of a line in a multi-line string literal to escape the newline."# ,
201
- characters: [
202
- Character ( " # " )
203
- ] ,
204
- swiftCharacters: [
205
- Character ( " # " )
206
- ]
159
+ characters: [ " # " ]
207
160
) ,
208
161
209
162
Trivia (
210
163
name: " Space " ,
211
164
comment: #"A space ' ' character."# ,
212
- characters: [
213
- Character ( " " )
214
- ] ,
215
- swiftCharacters: [
216
- Character ( " " )
217
- ] ,
165
+ characters: [ " " ] ,
218
166
traits: [ . whitespace, . spaceOrTab]
219
167
) ,
220
168
221
169
Trivia (
222
170
name: " Tab " ,
223
171
comment: #"A tab '\t' character."# ,
224
- characters: [
225
- Character ( " \t " )
226
- ] ,
227
- swiftCharacters: [
228
- Character ( " \t " )
229
- ] ,
172
+ characters: [ " \t " ] ,
230
173
traits: [ . whitespace, . spaceOrTab]
231
174
) ,
232
175
@@ -239,12 +182,7 @@ public let TRIVIAS: [Trivia] = [
239
182
Trivia (
240
183
name: " VerticalTab " ,
241
184
comment: #"A vertical tab '\v' character."# ,
242
- characters: [
243
- Character ( " \u{b} " )
244
- ] ,
245
- swiftCharacters: [
246
- Character ( " \u{2B7F} " )
247
- ] ,
185
+ characters: [ " \u{000B} " ] ,
248
186
traits: [ . whitespace]
249
187
) ,
250
188
]
0 commit comments