Improving Swift Tools with libSyntax
summary
libSyntax provides a concrete tree that preserves every token and trivia, exposes three construction APIs (make/with/builder APIs) and lets code be transformed by visitors like SyntaxRewriter passes. Demo builds a small Swift formatter that runs three token-level passes to fix brace placement, normalize spacing around =, and remove unnecessary semicolons; the demo runs and rewrites files live. Library is usable for formatting now but the parser integration is incomplete so many nodes appear as unknown and need further work.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 0:38Compilers
- 3:25Swift AST
- 4:20libSyntax
- 5:06Syntax Transformation
- 6:19Syntax Tree Structure
- 7:41Trivia Rules
- 9:49SyntaxData
- 10:48SyntaxNodes
- 11:28SyntaxAPIs
- 11:52MakeAPIs
- 12:33Transform Nodes
- 13:03Builders
- 14:17Guiding Principles
- 15:18Demo
- 20:27Conclusion
related talks
33mMaking Your Own Tools Using SwiftSyntax
06mFundamentals for Building Convenience with SwiftSyntax
27mSwiftSyntax: for good and evil
27mAST Meta-programming
28mSwiftly Swift manipulation... with Swift
31mMake your own code formatter in Swift
21mUnlock the Potential of Swift Code Generation
29mMy Little Parser: Tooling is Magic
