| With the widespread application of the C++14 standard in the market,the static analysis supporting the C+++14 standard is particularly important.Abstract Syntax Tree is the most basic data structure of program static analysis,and its integrity plays a vital role in static analysis results.However,lexical and parsing tools such as JavaCC(Java Compiler Compiler)cannot fully support many extended new features and complex syntax structures,which may cause the generation of syntax trees to fail and be incomplete.Aiming at the shortcomings of the existing lexical and syntax parsing tool JavaCC,which does not support the new C++standard and does not have a good fault-tolerant mechanism,this thesis proposes a new syntax tree construction method combining rule expansion and fault-tolerant processing.Focusing on this method,this thesis mainly did the following research:(1)Aiming at the limitation of rule files,a set of rule expansion methods oriented to grammar changes is proposed.Firstly,the grammar differences are extracted according to the current status of the rule file support and the C++14 standard;secondly,a set of general expansion methods of lexical and grammar rules for future grammar updates are proposed;finally,the rule file is modified to enhance the grammar recognition ability.(2)Aiming at the problem of interrupt analysis in the construction of syntax tree,a fault-tolerant processing framework for abstract syntax tree generation is proposed.Firstly,the generation errors of the syntax tree are classified and a fault-tolerant processing framework for the generation of the abstract syntax tree is proposed.Then,it proposes algorithms such as source program interval annotation,intermediate file verification and completion,syntax tree segmentation reconstruction,error symbol table elimination are proposed to complete fault-tolerant processing,so that the analysis is not interrupted when an error occurs.This thesis conducts experimental evaluation on the results of syntax tree construction with 6 open source projects in accordance with the C++14 standard.The experimental results show that after the rules expansion,the completion rate of syntax tree increases by 18.90%,and the number of analysis lines increases by 1.4 times;After fault tolerance,the completion rate of syntax tree increases by 44.47%,and the number of analyzed lines increases by 3 times.In general,the syntax tree construction method for the C++14 standard proposed in this thesis has a better performance than the traditional construction method in terms of the integrity of the abstract syntax tree and the adaptability to new grammars. |