TreeRegex is an extension of regular expressions to handle tree-like structures in text. Basically, it lets you use regular expression-like matching and replace on source code without worrying about parentheses matching problems.
TreeRegexLib is our reference implementation, available here, and we provide several tools to get started using TreeRegex.
Using TreeRegex requires four steps:
Fast: TreeRegexLib (our reference implementation) performs hundreds of times faster than Perl regular expressions for comparable tasks!
Easy to use: TreeRegex doesn’t require (re)writing a grammar or porting your entire build system to an esoteric build environment.
Quick to get started: Because TreeRegex is based heavily on regular expressions, anyone who knows regular expressions can easily get started.
Powerful: We are able to quickly implement instrumentation of if-statements or simple code transformations (as shown in the Tutorial).
Reliable: Languages and parsers change quickly, but by focusing on the outer-most layers of a tool chain (the syntax itself), TreeRegex lets users build tools that work for different versions of the language and different versions of the underlying tool chain (e.g., different versions of clang, even as the API is adjusted).
If you want to learn more, continue to the Tutorial