Giter VIP home page Giter VIP logo

swift-syntax's Introduction

SwiftSyntax

SwiftSyntax is a set of Swift libraries for parsing, inspecting, generating, and transforming Swift source code.

Documentation

You can read SwiftSyntax’s documentation on swiftpackageindex.com.

A great way to interactively explore the SwiftSyntax tree of a source file is https://swift-ast-explorer.com, developed by @kishikawakatsumi.

Adding SwiftSyntax as a Dependency

Trunk Development (main)

The mainline branch of SwiftSyntax tracks the latest developments. It is not an official release, and is subject to rapid changes in APIs and behaviors. To use it, add this repository to the Package.swift manifest of your project:

// swift-tools-version:5.7
import PackageDescription

let package = Package(
  name: "MyTool",
  dependencies: [
    .package(url: "https://github.com/apple/swift-syntax.git", branch: "main"),
  ],
  targets: [
    .target(name: "MyTool", dependencies: [
      .product(name: "SwiftSyntax", package: "swift-syntax"),
    ]),
  ]
)

Mainline SwiftSyntax also includes

  • SwiftParser for natively parsing source code
  • SwiftOperators for folding SwiftSyntax trees containing operators
  • SwiftSyntaxBuilder for generating Swift code with a result builder-style interface

Releases

Releases of SwiftSyntax are aligned with corresponding language and tooling releases and are stable. To use them, add this repository to the Package.swift manifest of your project:

// swift-tools-version:5.7
import PackageDescription

let package = Package(
  name: "MyTool",
  dependencies: [
    .package(url: "https://github.com/apple/swift-syntax.git", exact: "<#Specify Release tag#>"),
  ],
  targets: [
    .target(name: "MyTool", dependencies: [
      .product(name: "SwiftSyntax", package: "swift-syntax"),
    ]),
  ]
)

Replace <#Specify Release tag#> by the version of SwiftSyntax that you want to use (see the following table for mapping details).

Xcode Release Swift Release Tag SwiftSyntax Release Tag
Xcode 14.3 swift-5.8-RELEASE 508.0.0
Xcode 14.0 swift-5.7-RELEASE 0.50700.1
Xcode 13.3 swift-5.6-RELEASE 0.50600.1
Xcode 13.0 swift-5.5-RELEASE 0.50500.0
Xcode 12.5 swift-5.4-RELEASE 0.50400.0
Xcode 12.0 swift-5.3-RELEASE 0.50300.0
Xcode 11.4 swift-5.2-RELEASE 0.50200.0

Documentation

SwiftSyntax uses DocC bundles for its documentation. To view rendered documentation in Xcode, open the SwiftSyntax package and select

Product > Build Documentation

Associated articles are written in markdown, and can be viewed in a browser, text editor, or IDE.

Contributing

Start contributing to SwiftSyntax see this guide for more information.

Reporting Issues

If you should hit any issues while using SwiftSyntax, we appreciate bug reports on GitHub Issue.

Bazel

SwiftSyntax provides an experimental Bazel build configuration, maintained by Keith Smiley. To use it you can pull the source archive from the relevant release tag into your WORKSPACE and depend on the libraries you need from the BUILD.bazel file. Each library also has an associated Library_opt target (such as SwiftSyntax_opt) which forces SwiftSyntax to always build with optimizations enabled. This may help local runtime performance at the cost of debuggability, and initial build time. Please tag any issues related to the Bazel configuration with the label "Bazel".

License

Please see LICENSE for more information.

swift-syntax's People

Contributors

ahoppen avatar douggregor avatar kimdv avatar codafi avatar rintaro avatar fwcd avatar nkcsgexi avatar akyrtzi avatar bnbarham avatar hborla avatar hamishknight avatar stevenwong12 avatar stevapple avatar ttozzi avatar gottesmm avatar harlanhaskins avatar omochi avatar beccadax avatar kitasuke avatar evnik avatar slavapestov avatar flashspys avatar gibachan avatar allevato avatar zoecarver avatar rxwei avatar kavon avatar anthonylatsis avatar keith avatar simplydanny avatar

Watchers

 avatar

Forkers

atargis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.