Skip to content

Commit f5b808e

Browse files
committed
Remove Token Serialization Codes
1 parent 74e932c commit f5b808e

File tree

4 files changed

+266
-356
lines changed

4 files changed

+266
-356
lines changed

CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift.gyb

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
public class TokenSpec {
2323
public let name: String
2424
public let kind: String
25-
public let serializationCode: Int
2625
public let nameForDiagnostics: String
2726
public let unprefixedKind: String
2827
public let text: String?
@@ -44,7 +43,6 @@ public class TokenSpec {
4443
init(
4544
name: String,
4645
kind: String,
47-
serializationCode: Int,
4846
nameForDiagnostics: String,
4947
unprefixedKind: String? = nil,
5048
text: String? = nil,
@@ -55,7 +53,6 @@ public class TokenSpec {
5553
) {
5654
self.name = name
5755
self.kind = kind
58-
self.serializationCode = serializationCode
5956
self.nameForDiagnostics = nameForDiagnostics
6057
if let unprefixedKind = unprefixedKind {
6158
self.unprefixedKind = unprefixedKind
@@ -74,7 +71,6 @@ public class TokenSpec {
7471
public class KeywordSpec: TokenSpec {
7572
init(
7673
name: String,
77-
serializationCode: Int,
7874
text: String,
7975
classification: String = "Keyword",
8076
requiresLeadingSpace: Bool = false,
@@ -83,7 +79,6 @@ public class KeywordSpec: TokenSpec {
8379
super.init(
8480
name: name,
8581
kind: "kw_\(text)",
86-
serializationCode: serializationCode,
8782
nameForDiagnostics: text,
8883
unprefixedKind: text,
8984
text: text,
@@ -111,15 +106,13 @@ public class PoundKeywordSpec: TokenSpec {
111106
init(
112107
name: String,
113108
kind: String,
114-
serializationCode: Int,
115109
nameForDiagnostics: String? = nil,
116110
text: String,
117111
classification: String = "Keyword"
118112
) {
119113
super.init(
120114
name: name,
121115
kind: "pound_\(kind)",
122-
serializationCode: serializationCode,
123116
nameForDiagnostics: nameForDiagnostics ?? text,
124117
unprefixedKind: kind,
125118
text: text,
@@ -136,7 +129,6 @@ public class PoundObjectLiteralSpec: PoundKeywordSpec {
136129
init(
137130
name: String,
138131
kind: String,
139-
serializationCode: Int,
140132
text: String,
141133
classification: String = "ObjectLiteral",
142134
nameForDiagnostics: String,
@@ -146,7 +138,6 @@ public class PoundObjectLiteralSpec: PoundKeywordSpec {
146138
super.init(
147139
name: name,
148140
kind: kind,
149-
serializationCode: serializationCode,
150141
nameForDiagnostics: nameForDiagnostics,
151142
text: text,
152143
classification: classification
@@ -160,14 +151,12 @@ public class PoundDirectiveKeywordSpec: PoundKeywordSpec {
160151
init(
161152
name: String,
162153
kind: String,
163-
serializationCode: Int,
164154
text: String,
165155
classification: String = "PoundDirectiveKeyword"
166156
) {
167157
super.init(
168158
name: name,
169159
kind: kind,
170-
serializationCode: serializationCode,
171160
text: text,
172161
classification: classification
173162
)
@@ -178,14 +167,12 @@ public class PoundConditionalDirectiveKeywordSpec: PoundDirectiveKeywordSpec {
178167
override init(
179168
name: String,
180169
kind: String,
181-
serializationCode: Int,
182170
text: String,
183171
classification: String = "PoundDirectiveKeyword"
184172
) {
185173
super.init(
186174
name: name,
187175
kind: kind,
188-
serializationCode: serializationCode,
189176
text: text,
190177
classification: classification
191178
)
@@ -196,7 +183,6 @@ public class PunctuatorSpec: TokenSpec {
196183
init(
197184
name: String,
198185
kind: String,
199-
serializationCode: Int,
200186
text: String,
201187
classification: String = "None",
202188
requiresLeadingSpace: Bool = false,
@@ -205,7 +191,6 @@ public class PunctuatorSpec: TokenSpec {
205191
super.init(
206192
name: name,
207193
kind: kind,
208-
serializationCode: serializationCode,
209194
nameForDiagnostics: text,
210195
unprefixedKind: nil,
211196
text: text,
@@ -226,19 +211,19 @@ public let SYNTAX_TOKENS: [TokenSpec] = [
226211
% class_name = type(token).__name__
227212
% parameters = ["name: \"%s\"" % token.name]
228213
% if class_name in ['Keyword', 'SwiftKeyword', 'DeclKeyword', 'StmtKeyword', 'ExprKeyword', 'PatternKeyword', 'SilKeyword']:
229-
% parameters += ["serializationCode: %s" % token.serialization_code, "text: \"%s\"" % token.text]
214+
% parameters += ["text: \"%s\"" % token.text]
230215
% elif class_name in ['PoundKeyword', 'PoundConfig', 'PoundDirectiveKeyword', 'PoundConditionalDirectiveKeyword']:
231-
% parameters += ["kind: \"%s\"" % token.kind, "serializationCode: %s" % token.serialization_code, "text: \"%s\"" % token.text]
216+
% parameters += ["kind: \"%s\"" % token.kind, "text: \"%s\"" % token.text]
232217
% elif class_name in ['Punctuator', 'Misc', 'Literal']:
233-
% parameters += ["kind: \"%s\"" % token.kind, "serializationCode: %s" % token.serialization_code]
218+
% parameters += ["kind: \"%s\"" % token.kind]
234219
% if class_name != 'Punctuator':
235220
% parameters += ["nameForDiagnostics: \"%s\"" % token.name_for_diagnostics]
236221
% end
237222
% if token.text:
238223
% parameters += ["text: \"%s\"" % token.text]
239224
% end
240225
% elif class_name == 'PoundObjectLiteral':
241-
% parameters += ["kind: \"%s\"" % token.kind, "serializationCode: %s" % token.serialization_code, "text: \"%s\"" % token.text, "nameForDiagnostics: \"%s\"" % token.name_for_diagnostics, "protocol: \"%s\"" % token.protocol]
226+
% parameters += ["kind: \"%s\"" % token.kind, "text: \"%s\"" % token.text, "nameForDiagnostics: \"%s\"" % token.name_for_diagnostics, "protocol: \"%s\"" % token.protocol]
242227
% else:
243228
% print("Unknown token `%s`", (token.name), file=sys.stderr)
244229
% sys.exit(1)

0 commit comments

Comments
 (0)