Skip to content

Commit 5ab399a

Browse files
committed
Merge branch 'main' into ahoppen/basic-format-package
# Conflicts: # Code-Generation/Sources/SyntaxSupport/AttributeNodes.swift.gyb # Code-Generation/Sources/SyntaxSupport/AvailabilityNodes.swift.gyb # Code-Generation/Sources/SyntaxSupport/BuilderInitializableTypes.swift.gyb # Code-Generation/Sources/SyntaxSupport/Child.swift # Code-Generation/Sources/SyntaxSupport/Classification.swift.gyb # Code-Generation/Sources/SyntaxSupport/CommonNodes.swift.gyb # Code-Generation/Sources/SyntaxSupport/DeclNodes.swift.gyb # Code-Generation/Sources/SyntaxSupport/ExprNodes.swift.gyb # Code-Generation/Sources/SyntaxSupport/ExpressibleAsConformances.swift.gyb # Code-Generation/Sources/SyntaxSupport/GenericNodes.swift.gyb # Code-Generation/Sources/SyntaxSupport/Node.swift # Code-Generation/Sources/SyntaxSupport/NodeSerializationCodes.swift.gyb # Code-Generation/Sources/SyntaxSupport/PatternNodes.swift.gyb # Code-Generation/Sources/SyntaxSupport/StmtNodes.swift.gyb # Code-Generation/Sources/SyntaxSupport/SyntaxBaseKinds.swift.gyb # Code-Generation/Sources/SyntaxSupport/SyntaxNodes.swift # Code-Generation/Sources/SyntaxSupport/TokenSpec.swift.gyb # Code-Generation/Sources/SyntaxSupport/Traits.swift.gyb # Code-Generation/Sources/SyntaxSupport/Trivia.swift.gyb # Code-Generation/Sources/SyntaxSupport/TypeNodes.swift.gyb # Code-Generation/Sources/SyntaxSupport/Utils.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/AttributeNodes.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/AvailabilityNodes.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/BuilderInitializableTypes.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/Classification.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/CommonNodes.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/DeclNodes.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/ExprNodes.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/ExpressibleAsConformances.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/GenericNodes.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/NodeSerializationCodes.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/PatternNodes.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/StmtNodes.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/SyntaxBaseKinds.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/TokenSpec.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/Traits.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/Trivia.swift # Code-Generation/Sources/SyntaxSupport/gyb_generated/TypeNodes.swift # Code-Generation/Sources/SyntaxSupport/gyb_helpers/BuilderInitializableTypes.py # Code-Generation/Sources/SyntaxSupport/gyb_helpers/ExpressibleAsConformances.py # Code-Generation/Sources/SyntaxSupport/gyb_helpers/__init__.py # Code-Generation/Sources/SyntaxSupport/gyb_helpers/utils.py # Code-Generation/Sources/Utils/String+Extensions.swift # Code-Generation/Sources/Utils/SyntaxBuildableChild.swift # Code-Generation/Sources/Utils/SyntaxBuildableNode.swift # Code-Generation/Sources/Utils/SyntaxBuildableType.swift # Code-Generation/Sources/generate-swiftbasicformat/FormatFile.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/AttributeNodes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/AvailabilityNodes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/BuilderInitializableTypes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/Child.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/Classification.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/CommonNodes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/DeclNodes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/ExprNodes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/ExpressibleAsConformances.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/GenericNodes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/Node.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/NodeSerializationCodes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/PatternNodes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/StmtNodes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/String+Extensions.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/SyntaxBaseKinds.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/SyntaxBuildableChild.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/SyntaxBuildableNode.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/SyntaxBuildableType.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/SyntaxNodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/Templates/BuildableBaseProtocolsFile.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/Templates/BuildableCollectionNodesFile.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/Templates/BuildableNodesFile.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/Templates/ExpressibleAsProtocolsFile.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/Templates/FormatFile.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/Templates/TokenFile.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/TokenSpec.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/Traits.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/Trivia.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/TypeNodes.swift.gyb # Code-Generation/Sources/generate-swiftsyntaxbuilder/Utils.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/AttributeNodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/AvailabilityNodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/BuilderInitializableTypes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/Classification.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/CommonNodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/DeclNodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/ExprNodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/ExpressibleAsConformances.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/GenericNodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/NodeSerializationCodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/PatternNodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/StmtNodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/SyntaxBaseKinds.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/TokenSpec.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/Traits.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/Trivia.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_generated/TypeNodes.swift # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_helpers/BuilderInitializableTypes.py # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_helpers/ExpressibleAsConformances.py # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_helpers/__init__.py # Code-Generation/Sources/generate-swiftsyntaxbuilder/gyb_helpers/utils.py # CodeGeneration/Sources/generate-swiftsyntaxbuilder/AttributeNodes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/AvailabilityNodes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/BuildableBaseProtocolsFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/BuildableCollectionNodesFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/BuildableNodesFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/BuilderInitializableTypes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Child.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Classification.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/CommonNodes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/DeclNodes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/ExprNodes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/ExpressibleAsConformances.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/ExpressibleAsProtocolsFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/GenericNodes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Node.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/NodeSerializationCodes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/PatternNodes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/StmtNodes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/String+Extensions.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/SyntaxBaseKinds.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/SyntaxBuildableChild.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/SyntaxBuildableNode.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/SyntaxBuildableType.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/SyntaxNodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Templates/BuildableBaseProtocolsFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Templates/BuildableCollectionNodesFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Templates/BuildableNodesFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Templates/ExpressibleAsProtocolsFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Templates/FormatFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Templates/TokenFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/TokenFile.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/TokenSpec.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Traits.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Trivia.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/TypeNodes.swift.gyb # CodeGeneration/Sources/generate-swiftsyntaxbuilder/Utils.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/AttributeNodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/AvailabilityNodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/BuilderInitializableTypes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/Classification.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/CommonNodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/DeclNodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/ExprNodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/ExpressibleAsConformances.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/GenericNodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/NodeSerializationCodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/PatternNodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/StmtNodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/SyntaxBaseKinds.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/TokenSpec.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/Traits.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/Trivia.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_generated/TypeNodes.swift # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_helpers/BuilderInitializableTypes.py # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_helpers/ExpressibleAsConformances.py # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_helpers/__init__.py # CodeGeneration/Sources/generate-swiftsyntaxbuilder/gyb_helpers/utils.py # Sources/SwiftSyntaxBuilder/gyb_helpers/BuilderInitializableTypes.py # Sources/SwiftSyntaxBuilder/gyb_helpers/ExpressibleAsConformances.py # build-script.py
2 parents 86c555c + afea96f commit 5ab399a

File tree

126 files changed

+9679
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+9679
-32
lines changed
File renamed without changes.
File renamed without changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
%{
2+
from gyb_syntax_support import *
3+
from gyb_helpers import make_swift_child, make_swift_node
4+
# -*- mode: Swift -*-
5+
# Ignore the following admonition it applies to the resulting .swift file only
6+
}%
7+
//// Automatically Generated From AttributeNodes.swift.gyb.
8+
//// Do Not Edit Directly!
9+
//===----------------------------------------------------------------------===//
10+
//
11+
// This source file is part of the Swift.org open source project
12+
//
13+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
14+
// Licensed under Apache License v2.0 with Runtime Library Exception
15+
//
16+
// See https://swift.org/LICENSE.txt for license information
17+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
18+
//
19+
//===----------------------------------------------------------------------===//
20+
21+
public let ATTRIBUTE_NODES: [Node] = [
22+
% for node in ATTRIBUTE_NODES:
23+
${make_swift_node(node)},
24+
25+
% end
26+
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
%{
2+
from gyb_syntax_support import *
3+
from gyb_helpers import make_swift_child, make_swift_node
4+
# -*- mode: Swift -*-
5+
# Ignore the following admonition it applies to the resulting .swift file only
6+
}%
7+
//// Automatically Generated From AvailabilityNodes.swift.gyb.
8+
//// Do Not Edit Directly!
9+
//===----------------------------------------------------------------------===//
10+
//
11+
// This source file is part of the Swift.org open source project
12+
//
13+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
14+
// Licensed under Apache License v2.0 with Runtime Library Exception
15+
//
16+
// See https://swift.org/LICENSE.txt for license information
17+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
18+
//
19+
//===----------------------------------------------------------------------===//
20+
21+
public let AVAILABILITY_NODES: [Node] = [
22+
% for node in AVAILABILITY_NODES:
23+
${make_swift_node(node)},
24+
25+
% end
26+
]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
%{
2+
from gyb_syntax_support import *
3+
from gyb_helpers import BUILDER_INITIALIZABLE_TYPES
4+
# -*- mode: Swift -*-
5+
# Ignore the following admonition; it applies to the resulting .swift file only
6+
}%
7+
//// Automatically Generated From BuilderInitializableTypes.swift.gyb.
8+
//// Do Not Edit Directly!
9+
//===----------------------------------------------------------------------===//
10+
//
11+
// This source file is part of the Swift.org open source project
12+
//
13+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
14+
// Licensed under Apache License v2.0 with Runtime Library Exception
15+
//
16+
// See https://swift.org/LICENSE.txt for license information
17+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
18+
//
19+
//===----------------------------------------------------------------------===//
20+
21+
public let BUILDER_INITIALIZABLE_TYPES: [String: String?] = [
22+
% for type, resolved_type in BUILDER_INITIALIZABLE_TYPES.items():
23+
"${type}": ${'"' + resolved_type + '"' if resolved_type is not None else 'nil'},
24+
% end
25+
]
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
/// A child of a node, that may be declared optional or a token with a
14+
/// restricted subset of acceptable kinds or texts.
15+
public class Child {
16+
public let name: String
17+
public let syntaxKind: String
18+
public let description: String?
19+
public let collectionElementName: String?
20+
public let forceClassification: Bool
21+
public let isIndented: Bool
22+
public let requiresLeadingNewline: Bool
23+
public let isOptional: Bool
24+
public let textChoices: [String]
25+
public let nodeChoices: [Child]
26+
public let classification: SyntaxClassification?
27+
/// A restricted set of token kinds that will be accepted for this child.
28+
public let tokenChoices: [TokenSpec]
29+
public let tokenCanContainArbitraryText: Bool
30+
31+
public var swiftName: String {
32+
return lowercaseFirstWord(name: name)
33+
}
34+
35+
public var swiftSyntaxKind: String {
36+
return lowercaseFirstWord(name: syntaxKind)
37+
}
38+
39+
public var typeName: String {
40+
return kindToType(kind: syntaxKind)
41+
}
42+
43+
/// If the child ends with "token" in the kind, it's considered a token node. Grab the existing reference to that token from the global list.
44+
public var tokenKind: String? {
45+
if syntaxKind.hasSuffix("Token") {
46+
return syntaxKind
47+
} else {
48+
return nil
49+
}
50+
}
51+
52+
/// Returns `true` if this child has a token kind.
53+
public var isToken: Bool {
54+
return tokenKind != nil
55+
}
56+
57+
public var token: TokenSpec? {
58+
guard let tokenKind = tokenKind else { return nil }
59+
return SYNTAX_TOKEN_MAP[tokenKind]
60+
}
61+
62+
/// Returns the first choice from the `tokenChoices` if there are any, otherwise returns `nil`.
63+
public var mainToken: TokenSpec? {
64+
return tokenChoices.first
65+
}
66+
67+
/// Whether this child has syntax kind `UnexpectedNodes`.
68+
public var isUnexpectedNodes: Bool {
69+
syntaxKind == "UnexpectedNodes"
70+
}
71+
72+
/// If a classification is passed, it specifies the color identifiers in
73+
/// that subtree should inherit for syntax coloring. Must be a member of
74+
/// SyntaxClassification in SyntaxClassifier.h.gyb
75+
/// If force_classification is also set to true, all child nodes (not only
76+
/// identifiers) inherit the syntax classification.
77+
init(name: String,
78+
kind: String,
79+
description: String? = nil,
80+
isOptional: Bool = false,
81+
tokenChoices: [String] = [],
82+
textChoices: [String] = [],
83+
nodeChoices: [Child] = [],
84+
collectionElementName: String? = nil,
85+
classification: String? = nil,
86+
forceClassification: Bool = false,
87+
isIndented: Bool = false,
88+
requiresLeadingNewline: Bool = false) {
89+
self.name = name
90+
self.syntaxKind = kind
91+
self.description = description
92+
self.collectionElementName = collectionElementName
93+
self.classification = classificationByName(classification)
94+
self.forceClassification = forceClassification
95+
self.isIndented = isIndented
96+
self.requiresLeadingNewline = requiresLeadingNewline
97+
self.isOptional = isOptional
98+
99+
self.tokenChoices = tokenChoices.compactMap { SYNTAX_TOKEN_MAP["\($0)Token"] }
100+
101+
// If mappedTokenChoices contains `nil`, the token can contain arbitrary text
102+
self.tokenCanContainArbitraryText = self.tokenChoices.contains { $0.text == nil }
103+
104+
// A list of valid text for tokens, if specified.
105+
// This will force validation logic to check the text passed into the
106+
// token against the choices.
107+
self.textChoices = textChoices
108+
109+
// A list of valid choices for a child
110+
self.nodeChoices = nodeChoices
111+
112+
// Check the choices are either empty or multiple
113+
assert(nodeChoices.count != 1)
114+
115+
// Check node choices are well-formed
116+
for choice in self.nodeChoices {
117+
assert(!choice.isOptional, "node choice \(choice.name) cannot be optional")
118+
assert(choice.nodeChoices.isEmpty, "node choice \(choice.name) cannot have further choices")
119+
}
120+
}
121+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
%{
2+
from gyb_syntax_support import *
3+
from gyb_syntax_support.Token import *
4+
from gyb_syntax_support.kinds import lowercase_first_word
5+
# -*- mode: Swift -*-
6+
# Ignore the following admonition it applies to the resulting .swift file only
7+
}%
8+
//// Automatically Generated From Classification.swift.gyb.
9+
//// Do Not Edit Directly!
10+
//===----------------------------------------------------------------------===//
11+
//
12+
// This source file is part of the Swift.org open source project
13+
//
14+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
15+
// Licensed under Apache License v2.0 with Runtime Library Exception
16+
//
17+
// See https://swift.org/LICENSE.txt for license information
18+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
19+
//
20+
//===----------------------------------------------------------------------===//
21+
22+
/// Represents a classification a token can receive for syntax highlighting.
23+
public class SyntaxClassification {
24+
public let name: String
25+
public let description: String
26+
27+
public var swiftName: String {
28+
lowercaseFirstWord(name: name)
29+
}
30+
31+
public init(name: String, description: String) {
32+
self.name = name
33+
self.description = description
34+
}
35+
}
36+
37+
public let SYNTAX_CLASSIFICATIONS: [SyntaxClassification] = [
38+
% for syntaxClassification in SYNTAX_CLASSIFICATIONS:
39+
SyntaxClassification(name: "${syntaxClassification.name}", description: "${syntaxClassification.description.strip()}"),
40+
% end
41+
]
42+
43+
func classificationByName(_ name: String?) -> SyntaxClassification? {
44+
guard let name = name else { return nil }
45+
for classification in SYNTAX_CLASSIFICATIONS where classification.name == name {
46+
return classification
47+
}
48+
49+
fatalError("Unknown syntax classification '\(name)'")
50+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
%{
2+
from gyb_syntax_support import *
3+
from gyb_helpers import make_swift_child, make_swift_node
4+
# -*- mode: Swift -*-
5+
# Ignore the following admonition it applies to the resulting .swift file only
6+
}%
7+
//// Automatically Generated From CommonNodes.swift.gyb.
8+
//// Do Not Edit Directly!
9+
//===----------------------------------------------------------------------===//
10+
//
11+
// This source file is part of the Swift.org open source project
12+
//
13+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
14+
// Licensed under Apache License v2.0 with Runtime Library Exception
15+
//
16+
// See https://swift.org/LICENSE.txt for license information
17+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
18+
//
19+
//===----------------------------------------------------------------------===//
20+
21+
public let COMMON_NODES: [Node] = [
22+
% for node in COMMON_NODES:
23+
${make_swift_node(node)},
24+
25+
% end
26+
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
%{
2+
from gyb_syntax_support import *
3+
from gyb_helpers import make_swift_child, make_swift_node
4+
# -*- mode: Swift -*-
5+
# Ignore the following admonition it applies to the resulting .swift file only
6+
}%
7+
//// Automatically Generated From DeclNodes.swift.gyb.
8+
//// Do Not Edit Directly!
9+
//===----------------------------------------------------------------------===//
10+
//
11+
// This source file is part of the Swift.org open source project
12+
//
13+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
14+
// Licensed under Apache License v2.0 with Runtime Library Exception
15+
//
16+
// See https://swift.org/LICENSE.txt for license information
17+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
18+
//
19+
//===----------------------------------------------------------------------===//
20+
21+
public let DECL_NODES: [Node] = [
22+
% for node in DECL_NODES:
23+
${make_swift_node(node)},
24+
25+
% end
26+
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
%{
2+
from gyb_syntax_support import *
3+
from gyb_helpers import make_swift_child, make_swift_node
4+
# -*- mode: Swift -*-
5+
# Ignore the following admonition it applies to the resulting .swift file only
6+
}%
7+
//// Automatically Generated From ExprNodes.swift.gyb.
8+
//// Do Not Edit Directly!
9+
//===----------------------------------------------------------------------===//
10+
//
11+
// This source file is part of the Swift.org open source project
12+
//
13+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
14+
// Licensed under Apache License v2.0 with Runtime Library Exception
15+
//
16+
// See https://swift.org/LICENSE.txt for license information
17+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
18+
//
19+
//===----------------------------------------------------------------------===//
20+
21+
public let EXPR_NODES: [Node] = [
22+
% for node in EXPR_NODES:
23+
${make_swift_node(node)},
24+
25+
% end
26+
]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
%{
2+
from gyb_syntax_support import *
3+
from gyb_helpers import SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES
4+
# -*- mode: Swift -*-
5+
# Ignore the following admonition; it applies to the resulting .swift file only
6+
}%
7+
//// Automatically Generated From ExpressibleAsConformances.swift.gyb.
8+
//// Do Not Edit Directly!
9+
//===----------------------------------------------------------------------===//
10+
//
11+
// This source file is part of the Swift.org open source project
12+
//
13+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
14+
// Licensed under Apache License v2.0 with Runtime Library Exception
15+
//
16+
// See https://swift.org/LICENSE.txt for license information
17+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
18+
//
19+
//===----------------------------------------------------------------------===//
20+
21+
public let SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES: [String: [String]] = [
22+
% for buildable, conformances in SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES.items():
23+
"${buildable}": [
24+
% for conformance in conformances:
25+
"${conformance}",
26+
% end
27+
],
28+
% end
29+
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
%{
2+
from gyb_syntax_support import *
3+
from gyb_helpers import make_swift_child, make_swift_node
4+
# -*- mode: Swift -*-
5+
# Ignore the following admonition it applies to the resulting .swift file only
6+
}%
7+
//// Automatically Generated From GenericNodes.swift.gyb.
8+
//// Do Not Edit Directly!
9+
//===----------------------------------------------------------------------===//
10+
//
11+
// This source file is part of the Swift.org open source project
12+
//
13+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
14+
// Licensed under Apache License v2.0 with Runtime Library Exception
15+
//
16+
// See https://swift.org/LICENSE.txt for license information
17+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
18+
//
19+
//===----------------------------------------------------------------------===//
20+
21+
public let GENERIC_NODES: [Node] = [
22+
% for node in GENERIC_NODES:
23+
${make_swift_node(node)},
24+
25+
% end
26+
]

0 commit comments

Comments
 (0)