RulER: Automated Rule-Based Semantic Error Localization and Repair for Code Translation

📅 2025-09-18
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Existing automated code translation debugging methods rely on inaccurate code alignment and fixed patch templates, limiting their effectiveness in semantic error localization and repair. This paper proposes a rule-mining framework that leverages large language models (LLMs) to generate correct translation examples, introducing— for the first time—a scalable translation rule mechanism. The framework automatically extracts structured, cross-language mappings (e.g., Java/Python → C++) to enable dynamic statement-level alignment and adaptive patch generation. It eliminates dependence on manual alignment and predefined templates, supporting fine-grained expansion at both expression and lexical levels. Evaluated on outputs from four state-of-the-art translation models, our approach achieves up to a 20% improvement in error localization accuracy and a 272% increase in repair success rate over the best baselines—BatFix and TransMap—significantly outperforming direct LLM-based patch generation.

Technology Category

Application Category

📝 Abstract
Automated code translation aims to convert programs between different programming languages while maintaining their functionality. Due to the imperfections of code translation models, the generated translations may contain errors that compromise their reliability. Existing automated debugging methods for code translation rely on code alignments and repair patch templates to locate and fix erroneous translations. However, existing methods lack reliable references to construct code alignments and design repair patch templates, which significantly impacts their localization accuracy and repair effectiveness. To address these limitations, we reintroduce code translation rules and propose a rule-based debugging method for code translation, called RulER. RulER automatically derives code translation rules from correct translations generated by LLMs, enabling the efficient collection of diverse translation rules. In addition, RulER dynamically combines the existing rules on expandable nodes like expressions and tokens to further adaptively align more statements. These rules capture clear and detailed structural correspondences between source and target programming languages. Therefore, they can serve as reliable and reusable references for code alignment and repair template design, enabling RulER to locate and fix translation errors effectively. Our evaluation of RulER on Java-to-C++ and Python-to-C++ translations produced by four code translation models demonstrates that RulER outperforms state-of-the-art methods, BatFix and TransMap. Our experimental results show that RulER outperformed the best baseline by 20% and 272% in terms of error localization rates and repair success rates, respectively. RulER exhibits superior repair performance compared to directly prompting LLMs for patch generation, demonstrating a promising methodology for extracting and leveraging coding knowledge from LLMs.
Problem

Research questions and friction points this paper is trying to address.

Automated code translation generates errors compromising reliability
Existing debugging methods lack reliable references for alignment and repair
RulER derives rules from LLM translations to locate and fix errors
Innovation

Methods, ideas, or system contributions that make the work stand out.

Automatically derives translation rules from LLMs
Dynamically combines rules on expandable nodes
Uses rules as reliable references for alignment
🔎 Similar Papers
No similar papers found.