Skip to content

Commit 551ffd4

Browse files
authored
Merge pull request #1234 from kimdv/kimdv/move-trivia-from-gyn-to-code-gen
Move `Trivia` from gyb to code gen
2 parents 8841fd9 + 4e68377 commit 551ffd4

File tree

9 files changed

+731
-558
lines changed

9 files changed

+731
-558
lines changed

CodeGeneration/Sources/SyntaxSupport/Trivia.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ public let TRIVIAS: [Trivia] = [
6161
% ]
6262
% if trivia.characters:
6363
% spaces = 11
64-
% mapped_characters = list(map(lambda x: (' ' * spaces) + 'Character(#"%s"#)' % x, trivia.characters))
64+
% mapped_characters = list(map(lambda x: (' ' * spaces) + 'Character("%s")' % x, trivia.characters))
6565
% parameters += ['characters: [\n%s\n' % ',\n'.join(mapped_characters) + (' ' * (spaces - 2) + ']')]
6666
% end
6767
% if trivia.swift_characters:
6868
% spaces = 10
69-
% mapped_swift_characters = list(map(lambda x: (' ' * spaces) + 'Character(#"%s"#)' % x, trivia.swift_characters))
69+
% mapped_swift_characters = list(map(lambda x: (' ' * spaces) + 'Character("%s")' % x, trivia.swift_characters))
7070
% parameters += ['swiftCharacters: [\n%s\n' % ',\n'.join(mapped_swift_characters) + (' ' * (spaces - 2) + ']')]
7171
% end
7272
% if trivia.is_new_line:

CodeGeneration/Sources/SyntaxSupport/gyb_generated/Trivia.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,62 +52,62 @@ public let TRIVIAS: [Trivia] = [
5252
Trivia(name: "Space",
5353
comment: #"A space ' ' character."#,
5454
characters: [
55-
Character(#" "#)
55+
Character(" ")
5656
],
5757
swiftCharacters: [
58-
Character(#" "#)
58+
Character(" ")
5959
]),
6060
Trivia(name: "Tab",
6161
comment: #"A tab '\t' character."#,
6262
characters: [
63-
Character(#"\t"#)
63+
Character("\t")
6464
],
6565
swiftCharacters: [
66-
Character(#"\t"#)
66+
Character("\t")
6767
]),
6868
Trivia(name: "VerticalTab",
6969
comment: #"A vertical tab '\v' character."#,
7070
characters: [
71-
Character(#"\v"#)
71+
Character("\u{b}")
7272
],
7373
swiftCharacters: [
74-
Character(#"\u{2B7F}"#)
74+
Character("\u{2B7F}")
7575
]),
7676
Trivia(name: "Formfeed",
7777
comment: #"A form-feed 'f' character."#,
7878
characters: [
79-
Character(#"\f"#)
79+
Character("\u{c}")
8080
],
8181
swiftCharacters: [
82-
Character(#"\u{240C}"#)
82+
Character("\u{240C}")
8383
]),
8484
Trivia(name: "Newline",
8585
comment: #"A newline '\n' character."#,
8686
characters: [
87-
Character(#"\n"#)
87+
Character("\n")
8888
],
8989
swiftCharacters: [
90-
Character(#"\n"#)
90+
Character("\n")
9191
],
9292
isNewLine: true),
9393
Trivia(name: "CarriageReturn",
9494
comment: #"A newline '\r' character."#,
9595
characters: [
96-
Character(#"\r"#)
96+
Character("\r")
9797
],
9898
swiftCharacters: [
99-
Character(#"\r"#)
99+
Character("\r")
100100
],
101101
isNewLine: true),
102102
Trivia(name: "CarriageReturnLineFeed",
103103
comment: #"A newline consists of contiguous '\r' and '\n' characters."#,
104104
characters: [
105-
Character(#"\r"#),
106-
Character(#"\n"#)
105+
Character("\r"),
106+
Character("\n")
107107
],
108108
swiftCharacters: [
109-
Character(#"\r"#),
110-
Character(#"\n"#)
109+
Character("\r"),
110+
Character("\n")
111111
],
112112
isNewLine: true),
113113
Trivia(name: "LineComment",

CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct GenerateSwiftSyntax: ParsableCommand {
7373
TemplateSpec(sourceFile: syntaxVisitorFile, module: swiftSyntaxDir, filename: "SyntaxVisitor.swift"),
7474
TemplateSpec(sourceFile: tokenKindFile, module: swiftSyntaxDir, filename: "TokenKind.swift"),
7575
TemplateSpec(sourceFile: tokensFile, module: swiftSyntaxDir, filename: "Tokens.swift"),
76+
TemplateSpec(sourceFile: triviaFile, module: swiftSyntaxDir, filename: "Trivia.swift"),
7677

7778
// SwiftSyntaxBuilder
7879
TemplateSpec(sourceFile: buildableCollectionNodesFile, module: swiftSyntaxBuilderDir, filename: "BuildableCollectionNodes.swift"),

0 commit comments

Comments
 (0)