Files
swift-mirror/utils/gyb_syntax_support/kinds.py
Harlan a5098e6b69 Generate libSyntax API (#10926)
* 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.
2017-07-25 18:19:58 -07:00

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"