基于JavaCC的抽象语法树生成错误处理技术研究  被引量:3

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

在线阅读下载全文

作  者:王国隆 金大海[1] 宫云战[1] WANG Guolong;JIN Dahai;GONG Yunzhan(State Key Laboratory of Networking and Switching Technology,Beijing University of Posts and Telecommunications,Beijing 100876,China)

机构地区:[1]北京邮电大学网络与交换技术国家重点实验室,北京100876

出  处:《计算机测量与控制》2022年第2期151-159,共9页Computer Measurement &Control

基  金:国家自然科学基金(U1736110)。

摘  要:随着C++语言标准的不断演进,词法语法解析工具如JavaCC等对于很多扩充的新特性以及复杂的语法结构不能做到完全支持,这可能会导致抽象语法树生成错误且不完整;针对这一问题,提出一个针对抽象语法树生成错误的处理框架;首先,通过对JavaCC的扩充,实现一套可以解析C++语言的词法语法分析器,生成抽象语法树并记录报错行;其次,根据报错行寻找所在函数区间即不支持或不匹配的语法片段;最后,通过注释函数区间的方式来跳过不支持或不匹配的语法片段进行错误处理并迭代生成抽象语法树;实验结果表明,对抽象语法树生成进行错误处理后可以更全面的分析代码,抽象语法树完成率上升37.8%,分析行数提高3.9倍。With the continuous evolution of 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,an errors processing framework generated by abstract syntax trees is proposed.Firstly,through the extensible JavaCC,a set of lexical parsers that can parse C++compiler are implemented,the abstract syntax trees and record error lines are generated.Secondly,look for the grammatical fragments that are not supported or matched in the function range according to the error line.Finally,By annotating the function intervals,the 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 increases by 37.8%,and the number of analysis lines improves by 3.9 times.

关 键 词:抽象语法树 C++程序 JavaCC解析工具 语法变更 错误处理 

分 类 号:TP311[自动化与计算机技术—计算机软件与理论]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

相关的主题
相关的作者对象
相关的机构对象