These packages are available as a package collection, usable in Xcode or SwiftPM.
GrammarKit is a framework that can tokenize, parse, and generate abstract syntax trees for any grammatical language, in particular programming languages but also written languages like English, Spanish, and even custom languages.
1 package.