mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
* Generate libSyntax API This patch removes the hand-rolled libSyntax API and replaces it with an API that's entirely automatically generated. This means the API is guaranteed to be internally stylistically and functionally consistent.
21 lines
651 B
Python
21 lines
651 B
Python
"""
|
|
All the known base syntax kinds. These will all be considered non-final classes
|
|
and other types will be allowed to inherit from them.
|
|
"""
|
|
SYNTAX_BASE_KINDS = ['Decl', 'Expr', 'Pattern', 'Stmt',
|
|
'Syntax', 'SyntaxCollection', 'Type']
|
|
|
|
|
|
def kind_to_type(kind):
|
|
"""
|
|
Converts a SyntaxKind to a type name, checking to see if the kind is
|
|
Syntax or SyntaxCollection first.
|
|
A type name is the same as the SyntaxKind name with the suffix "Syntax"
|
|
added.
|
|
"""
|
|
if kind in ["Syntax", "SyntaxCollection"]:
|
|
return kind
|
|
if kind.endswith("Token"):
|
|
return "TokenSyntax"
|
|
return kind + "Syntax"
|