Where can I find standard BNF or YACC grammar for C++ language?

后端 未结 6 1147
小鲜肉
小鲜肉 2021-01-30 18:00

I\'m trying to work on a kind of code generator to help unit-testing an legacy C/C++ blended project. I don\'t find any kind of independent tool can generate stub code from decl

6条回答
  •  無奈伤痛
    2021-01-30 18:31

    Our DMS Software Reengineering Toolkit can be obtained with a robust, full featured C++ parser. See http://www.semanticdesigns.com/Products/FrontEnds/CppFrontEnd.html This builds ASTs and symbol tables, and can infer the type of any expression. DMS enables one to carry out arbitrary analyses and transformations on the C++ code.

    One "simple" transformation is instrumenting the code to collect test coverage data; we offer this as a COTS tool. See this paper to understand how DMS does it: http://www.semanticdesigns.com/Company/Publications/TestCoverage.pdf

    EDIT September 2013 (This answer was getting a bit stale): DMS's C++ parser/name resolution/control flow analysis handles full C++11, in the ISO-, GNU- and Microsoft variants. It will also parse (and retain) source code containing most preprocessor conditionals. It has an explicit grammar driving the parsing process, unlike GCC or Clang.

提交回复
热议问题