Analysis and Transformation of Source Code by Parsing and Rewriting

Jurgen J. Vinju. Analysis and Transformation of Source Code by Parsing and Rewriting. PhD thesis, nov 2005.


In this thesis the subject of study is source code. More precisely, I am inter- ested in tools that help in describing, analyzing and transforming source code. The overall question is how well qualified and versatile the programming language ASF+SDF is when applied to source code analysis and trans- formation. The main technical issues that are addressed are ambiguity of context-free languages and improving two important quality attributes of analyses and transformations: conciseness and fidelity. The overall result of this research is a version of the language that is bet- ter tuned to the domain of source code analysis and transformation, but is still firmly grounded on the original: a hybrid of context-free grammars and term rewriting. The results that are presented have a broad technical spectrum because they cover the entire scope of ASF+SDF. They include disambiguation by filtering parse forests, the type-safe automation of tree traversal for conciseness, improvements in language design resulting in higher resolution and fidelity, and better interfacing with other program- ming environments. Each solution has been validated in practice, by me and by others, mostly in the context of industrial sized case studies.