Click here to Skip to main content
16,010,268 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Updated 17-Jan-14 22:57pm
v2
Comments
OriginalGriff 18-Jan-14 4:35am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
What makes a cpp file "correct"? No compilation errors? No warnings? Runs without crashing?
Use the "Improve question" widget to edit your question and provide better information.
Richard MacCutchan 18-Jan-14 5:06am    
Check for what? If you want to check that the code is syntactically correct then you will need to read the C++ language reference, and write a syntax analyser that checks the code against those rules. This is not a simple project.
farhad bat 18-Jan-14 5:10am    
I want to check the code is syntactically correct but I don't want write c++ code analyser.
I want check it by cmd comment.how 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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900