基于JavaCC的抽象语法树生成错误处理技术研究
DOI:
CSTR:
作者:
作者单位:

北京邮电大学

作者简介:

通讯作者:

中图分类号:

基金项目:

国家自然科学基金项目(面上项目,重点项目,重大项目)


Research on Error Handling Technology of Abstract Syntax Tree Generation Based on JavaCC
Author:
Affiliation:

Fund Project:

  • 摘要
  • |
  • 图/表
  • |
  • 访问统计
  • |
  • 参考文献
  • |
  • 相似文献
  • |
  • 引证文献
  • |
  • 资源附件
  • |
  • 文章评论
    摘要:

    随着C++语言标准的不断演进,词法语法解析工具如JavaCC等对于很多扩充的新特性以及复杂的语法结构不能做到完全支持,这可能会导致抽象语法树生成错误且不完整。针对这一问题,提出一个针对抽象语法树生成错误的处理框架。首先,通过对JavaCC的扩充,实现一套可以解析C++语言的词法语法分析器,生成抽象语法树并记录报错行;其次,根据报错行寻找所在函数区间即不支持或不匹配的语法片段;最后,通过注释函数区间的方式来跳过不支持或不匹配的语法片段进行错误处理并迭代生成抽象语法树。实验结果表明,对抽象语法树生成进行错误处理后可以更全面的分析代码,抽象语法树完成率上升37.8%,分析行数提高3.9倍。

    Abstract:

    With the continuous evolution of the C++ language standard, lexical parsing tools such as JavaCC cannot fully support many expanded new features and complex grammatical structures, which may lead to incorrect and incomplete abstract syntax tree generation. Aiming at this problem, a framework for processing errors generated by abstract syntax trees is proposed. First, through the expansion of JavaCC, a set of lexical parsers that can parse C++ language are implemented, generate abstract syntax trees and record error lines; secondly, look for grammatical fragments that are not supported or do not match in the function range according to the error line; finally , By annotating function intervals, skip unsupported or unmatched grammar fragments for error handling and iteratively generate an abstract syntax tree. The experimental results show that the code can be analyzed more comprehensively after the error processing of the abstract syntax tree generation. The abstract syntax tree completion rate increased by 37.8%, and the number of analysis lines increased by 3.9 times.

    参考文献
    相似文献
    引证文献
引用本文

王国隆,金大海,宫云战.基于JavaCC的抽象语法树生成错误处理技术研究计算机测量与控制[J].,2022,30(2):151-159.

复制
分享
文章指标
  • 点击次数:
  • 下载次数:
  • HTML阅读次数:
  • 引用次数:
历史
  • 收稿日期:2021-11-30
  • 最后修改日期:2021-12-27
  • 录用日期:2021-12-31
  • 在线发布日期: 2022-02-22
  • 出版日期:
文章二维码