Grammar-Based Patches Generation for Automated Program Repair
34072Authors
nan
Abstract
Automated program repair (APR) aims to find an automatic solution to program lan- guage bugs without human intervention, and it can potentially reduce debugging costs and improve software quality. Conven- tional approaches adopt learning-based meth- ods such as sequence-to-sequence models for the patches generation. However, they tend to ignore the code structure information and suf- fer from grammar and syntax errors. To con- sider the grammar and syntax information, in this paper, we propose a grammar-based rule- to-rule model, which regards the repair pro- cess as the transformation of grammar rules, and leverages two encoders modeling both the original token sequence and the grammar rules, enhanced with a new tree-based self-attention. Besides, to guarantee grammar correctness, we employ a grammatically restricted infer- ence method to generate each grammar rule in a legally constrained sub-search-space consid- ering the generated previous rules. Experimen- tal evaluations on a Java dataset demonstrate that the proposed approach significantly out- performs the state-of-the-art baselines in terms of generated code accuracy. 1
Keywords
Full Content
Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, pages 1300–1305 August 1–6, 2021. ©2021 Association for Computational Linguistics 1300 Grammar-Based Patches Generation for Automated Program Repair Yu Tang1∗, Long Zhou2, Ambrosio Blanco2, Shujie Liu2, Furu Wei2, Ming Zhou2, Muyun Yang1 1Harbin Institute of Technology 19s103120@stu.hit.edu.cn yangmuyun@hit.edu.cn 2Microsoft Research Asia {lozhou,ambrosio.blanco,shujliu,fuwei,mingzhou}@microsoft.com Abstract Automated program repair (APR) aims to find an automatic solution to program lan- guage bugs without human intervention, and it can potentially reduce debugging costs and improve software quality. Conven- tional approaches adopt learning-based meth- ods such as sequence-to-sequence models for the patches generation. However, they tend to ignore the code structure information and suf- fer from grammar and syntax errors. To con- sider the grammar and syntax information, in this paper, we propose a grammar-based rule- to-rule model, which regards the repair pro- cess as the transformation of grammar rules, and leverages two encoders modeling both the original token sequence and the grammar rules, enhanced with a new tree-based self-attention. Besides, to guarantee grammar correctness, we employ a grammatically restricted infer- ence method to generate each grammar rule in a legally constrained sub-search-space consid- ering the generated previous rules. Experimen- tal evaluations on a Java dataset demonstrate that the proposed approach significantly out- performs the state-of-the-art baselines in terms of generated code accuracy. 1 Introduction Advances in machine learning and the availability of large corpora of source code have led to growing developments of software engineers. Researchers have exploited machine learning to automate sev- eral development and maintenance tasks, such as code completion (Svyatkovskiy et al., 2020), com- ment generation (Hu et al., 2018), code search (Gu et al., 2018), bug localization (Zheng et al., 2016) and fixing (Tufano et al., 2018). It’s worth noting that localizing and fixing bugs is known to be an effort-prone and time-consuming task for software developers (Weiss et al., 2007). Hence, several ∗Contribution during internship at Microsoft Research Method Type Identifier formal Block Parameters ( ) ( ) Type Identifier String name … modifiers Method Type Identifier formal Block Parameters ( ) ( ) Type Identifier String name … modifiers … Parameters Type Identifier int id Buggy : private UserName Initial ( String name) { return new UserName( name , id ) ; } R1: method-> modifiers type identifier parameters block R2: Modifiers -> private … R9: formal -> ( parameters ) … R1: method-> modifiers type identifier parameters block R2: Modifiers -> private … R9: formal -> ( parameters parameters ) R10:parameters -> type identifier … R9 is expanded with one “parameters.” Fixed : private UserName Initial ( String name , int id ) { return new UserName ( name , id ) ; } … … … … … Figure 1: Schematic diagram of our model. Source code is parsed into AST (Abstract Syntax Tree) and then into a sequence of rules. Each rule consists of one head token (parent node) and several tail tokens (chil- dren nodes). works recently focused on automatically repair- ing programs without human intervention, …
Content truncated to 500 words
Labeled Text
Automated program repair (APR) aims to find an automatic solution to program language bugs without human intervention, and it can potentially reduce debugging costs and improve software quality. Conventional approaches adopt learning-based methods such as sequence-to-sequence models for the patches generation. However, they tend to ignore the code structure information and suffer from grammar and syntax errors. To consider the grammar and syntax information, in this paper, we propose a grammar-based ruleto-rule model, which regards the repair process as the transformation of grammar rules, and leverages two encoders modeling both the original token sequence and the grammar rules, enhanced with a new tree-based self-attention. Besides, to guarantee grammar correctness, we employ a grammatically restricted inference method to generate each grammar rule in a legally constrained sub-search-space considering the generated previous rules. Experimental evaluations on a Java dataset demonstrate that the proposed approach significantly outperforms the state-of-the-art baselines in terms of generated code accuracy. 1
Publication Details
- Paper ID:
- 34072
- Year:
- 2021
- Publication:
- TIPSTER
- Publication Type:
- conf
- DOI:
- nan