Skip to content

Commit 54e4440

Browse files
authored
Merge pull request #1089 from CodaFi/a-serial-liar
2 parents e3e7b33 + ffbf4b9 commit 54e4440

File tree

11 files changed

+285
-1054
lines changed

11 files changed

+285
-1054
lines changed

CodeGeneration/Package.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ let package = Package(
4848
"DeclNodes.swift.gyb",
4949
"ExprNodes.swift.gyb",
5050
"GenericNodes.swift.gyb",
51-
"NodeSerializationCodes.swift.gyb",
5251
"PatternNodes.swift.gyb",
5352
"StmtNodes.swift.gyb",
5453
"SyntaxBaseKinds.swift.gyb",

CodeGeneration/Sources/SyntaxSupport/NodeSerializationCodes.swift.gyb

Lines changed: 0 additions & 24 deletions
This file was deleted.

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)

CodeGeneration/Sources/SyntaxSupport/Trivia.swift.gyb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
public class Trivia {
2121
public let name: String
2222
public let comment: String
23-
public let serializationCode: Int
2423
public let characters: [Character]
2524
public let swiftCharacters: [Character]
2625
public let isNewLine: Bool
@@ -34,13 +33,12 @@ public class Trivia {
3433

3534
init(name: String,
3635
comment: String,
37-
serializationCode: Int, characters: [Character] = [],
36+
characters: [Character] = [],
3837
swiftCharacters: [Character] = [],
3938
isNewLine: Bool = false,
4039
isComment: Bool = false){
4140
self.name = name
4241
self.comment = comment
43-
self.serializationCode = serializationCode
4442
self.isNewLine = isNewLine
4543
self.isComment = isComment
4644
self.characters = characters
@@ -60,7 +58,6 @@ public let TRIVIAS: [Trivia] = [
6058
% parameters = [
6159
% 'name: "%s"' % trivia.name,
6260
% 'comment: #"%s"#' % trivia.comment,
63-
% 'serializationCode: %d' % trivia.serialization_code
6461
% ]
6562
% if trivia.characters:
6663
% spaces = 11

0 commit comments

Comments
 (0)