Most effective way to parse C-like definition strings?

前端 未结 5 1187
滥情空心
滥情空心 2021-01-13 08:24

I\'ve got a set of function definitions written in a C-like language with some additional keywords that can be put before some arguments(the same way as \"unsigned\" or \"re

5条回答
  •  执笔经年
    2021-01-13 08:59

    For what you want to do, our DMS Software Reengineering Toolkit is likely a very effective solution.

    DMS is designed specifically to support customer analyzers/code generators of the type you are discussing. It provides very strong facilities for defining arbitrary language parsers/analyzers (tested on 30+ real languages including several complete dialects of C, C++, Java, C#, and COBOL).

    DMS automates the construction of ASTs (so you don't have to do anything but get the grammar right to have a usable AST), enables the construction of custom analyses of exactly the pattern-directed inspection you indicated, can construct new C-specific ASTs representing the code you want to generate, and spit them out as compilable C source text. The pre-existing definitions of C for DMS can likely be bent to cover your C-like language.

提交回复
热议问题