如何通过c#检查cpp文件是否正确 [英] how check cpp file that correct by c#
问题描述
我想用c#编写一个程序来提供一个cpp文件并检查它是否正确或不正确。如果它是正确的显示调用堆栈的cpp文件。
我不想编写编译器。我只想检查cpp file.how我这样做?
请看这里:http://msdn.microsoft.com/en-us/library/ms235639.aspx [ ^ ] - 你需要通过Process类来完成它,但它是可能的。
Quote:我不想编写编译器。我只想检查cpp file.how我这样做?
但是你必须编写编译器的两个主要组件,即
词法分析器
和解析器
。由于C ++
是一种非常复杂的语言,你的任务很困难,你可能需要一个库来完成它(除非你手上有大量的时间)。请查看DMS®软件重组工具包 [ ^ ]。如果您可以使用Java
,那么ANTLR
是一个选项(您可以找到C ++
grammars)。
如前所述,另一个选项是使用实际的C ++
编译器来执行验证。
I want write a program with c# that give a cpp file and check it to see it is correct or not correct. if it is correct show call stack of cpp file.
I don't want to write compiler. I just want check cpp file.how I do it?
See here: http://msdn.microsoft.com/en-us/library/ms235639.aspx[^] - you will need to do it via the Process class, but it is possible.
Quote:I don't want to write compiler. I just want check cpp file.how I do it?
However you have to write two major components of a compiler, namely the
lexical analyzer
and theparser
. SinceC++
is a really complex language your task is difficult and you probably need a library in order to accomplish it (unless you have a huge amount of time in your hands). Have a look at DMS® Software Reengineering Toolkit™[^]. If you could useJava
thenANTLR
is an option (you may find availableC++
grammars).
Another option, as already suggested, is using an actualC++
compiler to perform the validation.
这篇关于如何通过c#检查cpp文件是否正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!