awesome-repositories.com
Blog
MCP
awesome-repositories.com

Discover the best open-source repositories with AI-powered search.

ExploreCurated searchesOpen-source alternativesSelf-hosted softwareBlogSitemap
ProjectMCP serverAboutHow we rankPress
LegalPrivacyTerms
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
swiftlang avatar

swiftlang/swift-syntax

0
View on GitHub↗

Swift Syntax

SwiftSyntax is a set of Swift libraries for parsing, inspecting, generating, and transforming Swift source code. It parses source text into lossless syntax trees that keep every token, piece of trivia, and source position, so the original text can be rebuilt exactly. Those trees are the basis for the rest of the package: structural analysis, name lookup, diagnostics, and code rewriting.

The package also covers Swift macro development. It provides protocols and an expansion engine for writing macros that inspect annotated code and generate new code at compile time. Macros can be bundled into standalone compiler plugin executables, which the compiler launches and communicates with separately from its own process. A collection of sample macros and a utility for testing macro expansions against expected output are included. On the generation side, a builder interface constructs syntax trees programmatically and prints them as well-formed source, instead of relying on string concatenation.

Beyond parsing and macros, the libraries offer formatting, refactoring actions that can surface as editor commands in Xcode, and diagnostics with suggested fixes. Supporting capabilities include operator precedence folding, conditional compilation evaluation, lexical scope name resolution, and syntax classification for editor tooling. Syntax nodes are immutable, so each transformation produces a new tree that shares unchanged parts with the old one. Transformations are written with visitor and rewriter classes.

API reference documentation is published for each library target, and an interactive browser-based explorer lets you view the syntax tree of any source file.

AI search

Explore more awesome repositories

Describe what you need in plain English — the AI ranks thousands of curated open-source projects by relevance.

Start searching with AI

Features

  • Source File Parsing - Parses Swift source text into lossless syntax trees that keep every token, piece of trivia, and source position.
  • Swift Source Parsers - Parses Swift source into lossless syntax trees preserving every token, trivia, and position so the original text can be rebuilt exactly.
  • Compile-Time Macros - Supports writing compile-time macros that inspect annotated code and expand into generated code, packaged as plugins the compiler loads.
  • Compiler Plugin Executables - Builds standalone plugin executables that the compiler launches and talks to in order to run custom macro logic while compiling.
  • Compiler Plugin SDKs - Lets macro logic be bundled into standalone executables that the compiler launches and communicates with outside its own process.
  • Attribute-Macro Code Generators - Lets macros produce syntax nodes that the expansion inserts into source files, forming the basis of the macro system.
  • Procedural Macro Engines - Provides protocols and an expansion engine for writing macros that inspect annotated code and generate new code at compile time.
  • Macro Expansion Frameworks - Provides role-specific protocols and an expansion engine that splice macro-generated nodes into source files at compile time.
  • Source Code Generators - Builds syntax trees programmatically through builder interfaces and prints them as well-formed source text instead of concatenating strings.
  • Swift Source Analysis - Parses Swift into accurate syntax trees for structural inspection, name resolution, token classification, and diagnostics with suggested fixes.
  • Lossless Semantic Trees - Models source as a tree that keeps every token, whitespace, comment and position so the original text can be rebuilt exactly.
  • Out-of-Process Plugin Architectures - Runs macros in standalone executables that the compiler launches and communicates with via serialized messages, isolating custom logic.
  • Syntax Tree Construction - Models source code as an immutable tree of nodes preserving program structure, tokens, and trivia for inspection and manipulation.
  • Code Refactoring Tools - Provides reusable refactoring actions that rewrite code structure on syntax trees while keeping surrounding source intact.
  • Swift Code Generators - Provides a builder interface that constructs valid Swift source instead of string concatenation, with generated files rebuilt from definitions.
  • Swift Refactoring Tools - Offers a framework of reusable refactoring actions that rewrite and format syntax trees and can appear as Xcode editor commands.
  • Build Plugin Compilation - Bundles macro implementations into a standalone plugin program that the compiler loads and runs during compilation.
  • Custom Macro Definitions - Supports defining reusable macros that expand into generated code at compile time, with ready-to-run samples to learn from.
  • Swift Source Code Transformers - Transforms Swift source by walking its syntax tree with rewriters, including a command-line example that increments every integer literal.
  • Swift Development Tooling - Supplies syntax classification, diagnostics with fix-its, name lookup, and operator precedence folding that editors and IDEs build on.
  • Swift Refactoring Tools - Offers reusable refactoring actions and syntax tree rewriting that transform Swift code structure, including commands that surface in Xcode.
  • Immutable Nodes - Syntax nodes are immutable, so each transformation yields a new tree that shares unchanged parts with the previous one.
  • Builder-Based Source Generation - Constructs source files from structured builder calls that produce syntax nodes, guaranteeing well-formed output without string concatenation.
  • Syntax Tree Transformers - Offers visitor and rewriter classes that override specific node types and return replacements while leaving untouched code intact.
  • Parser Diagnostics Reporting - Creates errors, warnings and suggested fixes tied to source locations and detects problems in parsed code with correction hints.
3,720 stars·565 forks·Swift·Apache-2.0·5 views

Star history

Star history chart for swiftlang/swift-syntaxStar history chart for swiftlang/swift-syntax

How this analysis was created: This summary and feature list are AI-generated from collected project material and can contain mistakes. Stars, license and language are imported from GitHub. Inclusion does not mean that we have tested or audited this project. Check the source documentation for any feature you depend on. Learn more on our About page.

Projects sharing features with Swift Syntax

These projects share indexed features with Swift Syntax. Shared tags can include platform or build tooling; verify the primary use case before treating a result as a replacement.
  • apple/swift-syntaxapple avatar

    apple/swift-syntax

    3,671View on GitHub↗

    swift-syntax is a library for parsing, manipulating, and generating Swift source code. It provides a source-accurate abstract syntax tree representation of Swift code, acting as a parser, transformer, and code generator. The project serves as the infrastructure for Swift macro development, enabling the expansion and transformation of source code during compilation. It is used to build compiler tooling for static analysis, formatting, and automated refactoring. The system covers a broad range of source analysis capabilities, including the ability to convert source code into structured trees f

    Swift
    View on GitHub↗3,671
  • nicklockwood/swiftformatnicklockwood avatar

    nicklockwood/SwiftFormat

    8,835View on GitHub↗

    SwiftFormat is a tool for the Swift language that functions as a code formatter, linter, and refactoring utility. It automatically applies consistent style rules and visual formatting to source files to ensure a uniform appearance across a project. The project differentiates itself by providing both a command-line interface for batch processing and an Xcode extension for integration directly into the development environment. It includes specialized capabilities for modernizing legacy API usage, simplifying language constructs, and inferring formatting options by analyzing an existing codebase

    Swift
    View on GitHub↗8,835
  • c3lang/c3cc3lang avatar

    c3lang/c3c

    5,933View on GitHub↗

    c3c is the compiler for the C3 programming language, transforming source code into executable binaries, static libraries, or dynamic libraries using an LLVM backend. It implements a system based on result-based error handling, scoped memory pooling, and a semantic macro system. The compiler provides first-class support for hardware-backed SIMD vectors that map directly to processor instructions and enables runtime polymorphism through interface-based dynamic dispatch. The project covers a broad set of low-level capabilities, including manual and pooled memory management, inline assembly inte

    C3c3compilerlanguage
    View on GitHub↗5,933
  • benjamn/recastbenjamn avatar

    benjamn/recast

    5,246View on GitHub↗

    Recast is a JavaScript AST parser and printer designed for automated code refactoring. It converts source code into abstract syntax trees that can be modified and then printed back into source code. The project focuses on formatting-preserving transformations, storing original whitespace and indentation metadata within syntax tree nodes to reconstruct code without losing its original layout. It also generates character-level source maps to maintain precise correspondences between original input and transformed output. The toolkit includes utilities for syntax tree manipulation using a visito

    TypeScript
    View on GitHub↗5,246
Compare all 30 related projects→

Frequently asked questions

What does swiftlang/swift-syntax do?

SwiftSyntax is a set of Swift libraries for parsing, inspecting, generating, and transforming Swift source code. It parses source text into lossless syntax trees that keep every token, piece of trivia, and source position, so the original text can be rebuilt exactly. Those trees are the basis for the rest of the package: structural analysis, name lookup, diagnostics, and code rewriting.

What are the main features of swiftlang/swift-syntax?

The main features of swiftlang/swift-syntax are: Source File Parsing, Swift Source Parsers, Compile-Time Macros, Compiler Plugin Executables, Compiler Plugin SDKs, Attribute-Macro Code Generators, Procedural Macro Engines, Macro Expansion Frameworks.

Which projects share features with swiftlang/swift-syntax?

Projects with overlapping indexed features include: apple/swift-syntax — swift-syntax is a library for parsing, manipulating, and generating Swift source code. It provides a source-accurate… nicklockwood/swiftformat — SwiftFormat is a tool for the Swift language that functions as a code formatter, linter, and refactoring utility. It… c3lang/c3c — c3c is the compiler for the C3 programming language, transforming source code into executable binaries, static… benjamn/recast — Recast is a JavaScript AST parser and printer designed for automated code refactoring. It converts source code into… dtolnay/syn — syn is a Rust syntax tree parser and token stream converter. It serves as a toolkit for procedural macro development,… openrewrite/rewrite — OpenRewrite is an automated refactoring engine and source-to-source migration framework. It uses a lossless semantic…