According to the specific requirements for the safety check, a method based on a parser generator, ANTLR, for constructing the preprocessor of a C/C++ program safety checker is proposed and implemented in this paper. The preprocessor provide the intermediate file for the back-end of the safety checker by analyzing the source code of the project.ANTLR is utilized to construct the framework of preprocessor's lexer and parser. Also, the standard of the C/C++ preprocess, the design and implementation of the preprocessor and it's safety check module are detailedly discussed in the paper. It is proved that the preprocessor can satisfy the requirements for the safety checker. |