基于深度学习的编译型语言代码转换技术研究OA
Research on Compiler Language Code Conversion Technology Based on Deep Learning
随着软件系统跨平台和语言多样化的需求日益增长,自动源代码转换技术成为现代软件工程中的关键研究方向.传统基于规则和统计方法的代码转换手段受限于语法覆盖范围小、语义一致性弱等问题,难以满足大规模、高精度的代码迁移需求.该文聚焦于编译型语言之间的代码转换任务,提出一种基于深度学习的Java到C++自动代码转换方法.该方法融合了Transformer编码-解码结构、语法树建模、层次注意力机制和指针生成机制,能够同时捕捉源代码的词法和结构特征,并有效处理未登录标识符的翻译问题.在构建的Java-C++平行数据集上开展了系统实验,结果表明该模型在BLEU得分提升了6.4 百分点,CodeBLEU提升了4.7 百分点,精确匹配率提高了5.7 百分点,功能正确率提高了7.8 百分点,在多个评价指标上均显著优于现有主流方法.通过消融实验和案例分析进一步验证了模型结构各部分对性能提升的重要贡献.
With the increasing demand for cross-platform and language diversity of software systems,automatic source code conversion technology has become a key research direction in modern software engineering.Traditional code conversion methods based on rules and statistical approaches are limited by problems such as small grammar coverage and weak semantic consistency,making it difficult to meet the requirements of large-scale and high-precision code migration.We focus on the code conversion task between compiled languages and propose an automatic code conversion method from Java to C++based on deep learning.This method integrates the Transformer encoder-decoding structure,syntactic tree modeling,hierarchical attention mechanism and pointer generation mechanism,which can sim-ultaneously capture the lexical and structural features of the source code and effectively handle the translation problem of unregistered identifiers.We conduct systematic experiments on the constructed Java-C++parallel dataset.The results show that the proposed model has increased the BLEU score by6.4 percentage points,the CodeBLEU score by4.7 percentage points,the exact matching rate by 5.7 percentage points,and the functional accuracy rate by 7.8 percentage points.It is significantly superior to the existing mainstream methods in multiple evaluation indicators.
张明明;张富林;刘建戈;张鹏宇;洪涛
国网江苏省电力有限公司,江苏 南京 210009福建亿榕信息技术有限公司,福建 福州 350001国网江苏省电力有限公司,江苏 南京 210009国网江苏省电力有限公司,江苏 南京 210009国网江苏省电力有限公司,江苏 南京 210009
信息技术与安全科学
代码转换编译型语言Transformer语法树指针生成网络
code conversioncompiled languageTransformersyntax treepointer generation network
《计算机技术与发展》 2026 (1)
24-30,7
国家电网有限公司总部管理科技项目资助(5700-202418244A-1-1-ZN)
评论