如何通过c#检查cpp文件是否正确 [英] how check cpp file that correct by c#

查看:108
本文介绍了如何通过c#检查cpp文件是否正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用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 the parser. Since C++ 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 use Java then ANTLR is an option (you may find available C++ grammars).
Another option, as already suggested, is using an actual C++ compiler to perform the validation.


这篇关于如何通过c#检查cpp文件是否正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆