[Syntax] Swift libSyntax API (#11320)

* Create Swift libSyntax API

This patch is an initial implementation of the Swift libSyntax API. It
aims to provide all features of the C++ API but exposed to Swift.

It currently resides in SwiftExperimental and will likely exist in a
molten state for a while.

* Only build SwiftSyntax on macOS
This commit is contained in:
Harlan
2017-08-14 16:47:48 -07:00
committed by GitHub
parent fd253dabaf
commit ade67ca899
33 changed files with 2366 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
from __future__ import print_function
import sys # noqa: I201
from kinds import SYNTAX_BASE_KINDS, kind_to_type
from kinds import SYNTAX_BASE_KINDS, kind_to_type, lowercase_first_word
def error(msg):
@@ -19,6 +19,7 @@ class Node(object):
def __init__(self, name, kind=None, children=None,
element=None, element_name=None):
self.syntax_kind = name
self.swift_syntax_kind = lowercase_first_word(name)
self.name = kind_to_type(self.syntax_kind)
self.children = children or []