Abstract

Transformations between source codes, such as refactorings and program analysis, are frequently used in software engineering. Typically, transformations are effectively implemented using an abstract syntax tree (AST) on the origin source code. However, a critical limitation of ASTs is the loss of layout information such as whitespace and comments, which can result in poor readability. To overcome this shortcoming, this paper proposes a bidirectional transformation (BX) method that maintains consistency in the layout between the origin and transformed. First, a section of origin source code will be translated to a concrete syntax tree (CST) that includes layout information. Second, to make the BX practical, a new method is constructed that matches an AST with its respective CST. Finally, to get a reasonable CST, a method to amend the CST is also provided. We prove that the BX is well-behaved, which implies that it satisfies both the PutGet and GetPut laws. Furthermore, we illustrate the correctness of the methodology by treating XML language as a case study.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call