Transpilation using Recursive Rewrite Rules: From Legacy to Maintainable Code

conference paper
Software systems often depend on third-party components, such as libraries and frameworks. When these components become deprecated, maintenance is required to ensure the continued functionality of these systems. In this paper, we present a case study at ASML, one of the world’s leading manufacturers of chip-making equipment, involving the deprecation of a UI framework, which necessitated the transpilation of part of an
industrial code base from C to Python. ASML estimated that manual transpilation would require 100 man-years of effort. To significantly reduce this effort, we developed a novel rejuvenation methodology based on three key pillars aimed at producing maintainable code in the target language. The first pillar focuses on efficient transpilation through source code analysis that quantifies the frequency of recurring patterns – such as variable initialization, UI framework calls, and function definitions – by prioritizing the automation of the most frequently recurring patterns. The second pillar automates the transpilation by using a novel rule-based recursive rewrite system that matches concrete syntax patterns with placeholders to sequences of AST nodes, rewrites the placeholders within the matches recursively, and has default rules for unmatched AST nodes that offer clear guidance for manual transpilation. The third pillar focuses on generating test cases, first to capture usage context and, second to detect functional regression. Awareness of the usage context enables idiomatic rather than literal transpilation, resulting in more readable and maintainable code in the target language. We validated our methodology using two components dependent on the deprecated UI framework. ASML estimates that applyingthis methodology will reduce the required effort by 70%, demonstrating the effectiveness of our strategy.
TNO Identifier
1028894
ISSN
2640-7574
Publisher
IEEE
Source title
2026 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER)
Pages
205-215
Files
To receive the publication files, please send an e-mail request to TNO Repository.