|
1 |
| -# SwiftSyntax |
| 1 | +# Swift Syntax |
2 | 2 |
|
3 |
| -SwiftSyntax is a set of Swift libraries for parsing, inspecting, generating, and transforming Swift source code. |
| 3 | +The swift-syntax package is a set of libraries that work on a source-accurate tree representation of Swift source code, called the SwiftSyntax tree. The SwiftSyntax tree forms the backbone of Swift’s macro system – the macro expansion nodes are represented as SwiftSyntax nodes and a macro generates a SwiftSyntax tree to be inserted into the source file. |
4 | 4 |
|
5 | 5 | ## Documentation
|
6 | 6 |
|
7 | 7 | You can read SwiftSyntax’s documentation on [swiftpackageindex.com](https://swiftpackageindex.com/apple/swift-syntax/documentation).
|
8 | 8 |
|
9 | 9 | A great way to interactively explore the SwiftSyntax tree of a source file is https://swift-ast-explorer.com, developed by [@kishikawakatsumi](https://github.com/kishikawakatsumi).
|
10 | 10 |
|
11 |
| -## Adding SwiftSyntax as a Dependency |
| 11 | +A set of example usages of swift-syntax can be found in [Examples](Examples). |
12 | 12 |
|
13 |
| -### Trunk Development (main) |
| 13 | +## Releases |
14 | 14 |
|
15 |
| -The mainline branch of SwiftSyntax tracks the latest developments. It is not |
16 |
| -an official release, and is subject to rapid changes in APIs and behaviors. To |
17 |
| -use it, add this repository to the `Package.swift` manifest of your project: |
| 15 | +Releases of SwiftSyntax are aligned with corresponding language and tooling releases, for example the major version 509 of swift-syntax is aligned with Swift 5.9. |
18 | 16 |
|
19 |
| -```swift |
20 |
| -// swift-tools-version:5.7 |
21 |
| -import PackageDescription |
22 |
| - |
23 |
| -let package = Package( |
24 |
| - name: "MyTool", |
25 |
| - dependencies: [ |
26 |
| - .package(url: "https://github.com/apple/swift-syntax.git", branch: "main"), |
27 |
| - ], |
28 |
| - targets: [ |
29 |
| - .target(name: "MyTool", dependencies: [ |
30 |
| - .product(name: "SwiftSyntax", package: "swift-syntax"), |
31 |
| - ]), |
32 |
| - ] |
33 |
| -) |
34 |
| -``` |
35 |
| - |
36 |
| -Mainline SwiftSyntax also includes |
37 |
| - |
38 |
| -- `SwiftParser` for natively parsing source code |
39 |
| -- `SwiftOperators` for folding SwiftSyntax trees containing operators |
40 |
| -- `SwiftSyntaxBuilder` for generating Swift code with a result builder-style interface |
41 |
| -- `SwiftSyntaxMacros` for providing syntactic macro support |
42 |
| - |
43 |
| -### Releases |
44 |
| - |
45 |
| -Releases of SwiftSyntax are aligned with corresponding language |
46 |
| -and tooling releases and are stable. To use them, |
47 |
| -add this repository to the `Package.swift` manifest of your project: |
48 |
| - |
49 |
| -```swift |
50 |
| -// swift-tools-version:5.7 |
51 |
| -import PackageDescription |
52 |
| - |
53 |
| -let package = Package( |
54 |
| - name: "MyTool", |
55 |
| - dependencies: [ |
56 |
| - .package(url: "https://github.com/apple/swift-syntax.git", exact: "<#Specify Release tag#>"), |
57 |
| - ], |
58 |
| - targets: [ |
59 |
| - .target(name: "MyTool", dependencies: [ |
60 |
| - .product(name: "SwiftSyntax", package: "swift-syntax"), |
61 |
| - ]), |
62 |
| - ] |
63 |
| -) |
64 |
| -``` |
65 |
| - |
66 |
| -Replace `<#Specify Release tag#>` by the version of SwiftSyntax that you want to use (see the following table for mapping details). |
67 |
| - |
68 |
| -| Xcode Release | Swift Release Tag | SwiftSyntax Release Tag | |
69 |
| -|:-------------------:|:-------------------:|:-------------------------:| |
70 |
| -| Xcode 14.3 | swift-5.8-RELEASE | 508.0.0 | |
71 |
| -| Xcode 14.0 | swift-5.7-RELEASE | 0.50700.1 | |
72 |
| -| Xcode 13.3 | swift-5.6-RELEASE | 0.50600.1 | |
73 |
| -| Xcode 13.0 | swift-5.5-RELEASE | 0.50500.0 | |
74 |
| -| Xcode 12.5 | swift-5.4-RELEASE | 0.50400.0 | |
75 |
| -| Xcode 12.0 | swift-5.3-RELEASE | 0.50300.0 | |
76 |
| -| Xcode 11.4 | swift-5.2-RELEASE | 0.50200.0 | |
77 |
| - |
78 |
| -## Documentation |
79 |
| - |
80 |
| -SwiftSyntax uses [DocC](https://developer.apple.com/documentation/docc) bundles |
81 |
| -for its documentation. To view rendered documentation in Xcode, open the |
82 |
| -SwiftSyntax package and select |
83 |
| - |
84 |
| -``` |
85 |
| -Product > Build Documentation |
86 |
| -``` |
87 |
| - |
88 |
| -Associated articles are written in markdown, and can be viewed in a browser, |
89 |
| -text editor, or IDE. |
| 17 | +## Reporting Issues |
90 | 18 |
|
91 |
| -- [SwiftSyntax](Sources/SwiftSyntax/Documentation.docc) |
92 |
| -- [SwiftParser](Sources/SwiftParser/SwiftParser.docc) |
93 |
| -- [SwiftOperators](Sources/SwiftOperators/SwiftOperators.docc) |
94 |
| -- [SwiftSyntaxMacros](Sources/SwiftSyntaxMacros/SwiftSyntaxMacros.docc) |
| 19 | +If you should hit any issues while using SwiftSyntax, we appreciate bug reports on [GitHub Issue](https://github.com/apple/swift-syntax/issues). |
95 | 20 |
|
96 | 21 | ## Contributing
|
97 | 22 |
|
98 | 23 | Start contributing to SwiftSyntax see [this guide](CONTRIBUTING.md) for more information.
|
99 | 24 |
|
100 |
| -## Reporting Issues |
101 |
| - |
102 |
| -If you should hit any issues while using SwiftSyntax, we appreciate bug reports on [GitHub Issue](https://github.com/apple/swift-syntax/issues). |
103 |
| - |
104 | 25 | ## Bazel
|
105 | 26 |
|
106 | 27 | SwiftSyntax provides an experimental [Bazel](https://bazel.build) build configuration, maintained by Keith Smiley.
|
|
0 commit comments