C Code Parser for .NET

2019-04-29 09:27发布

Does anyone know of any C parser library for .NET?

(I'm intending to parse C code into some form of object graph, so I can convert it to a different language.)

标签: c# .net c parsing
3条回答
Summer. ? 凉城
2楼-- · 2019-04-29 09:56

First Option Raw class : You can extract scanner and parser class from this application. Part 1 : the scanner Part 2 the parser and part 3 the main program, in this code snippet :

https://www.daniweb.com/software-development/csharp/threads/453104/parsing-c-code-using-c

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-04-29 10:09

A proper C99 grammar is not that trivial. It's better to use a proven C parser (e.g., Clang). It is possible to use it with .NET via C++/CLI.

查看更多
爷、活的狠高调
4楼-- · 2019-04-29 10:10

ANTLR can do what you'd like. It has a C preprocessor and ANSI C grammar.

https://github.com/antlr/grammars-v4

查看更多
登录 后发表回答