I have created a Swift package (GitHub - daspoon/tree-sitter-kit: Tree-sitter integration for Swift.) enabling tree-sitter parsers to be written in Swift; specifically, as an array of production rules which map symbol types to pairings of syntax expression and type constructor. A member macro derives a tree-sitter grammar and embeds the generated parser in its expansion.
The macro relies on a fork of tree-sitter (GitHub - daspoon/tree-sitter: A fork of tree-sitter which extends the CLI library with a method to generate Swift parsing code.) which adds a callable API to generate Swift rather than C source.
This project is a work in progress, and I will be grateful for any feedback.
Thanks,
Dave