Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have to make a application which can write the description of any program wrtten by the user.the program can include the functions prototype or definition ,swith case,if else,for loop,do while loop and while loop.the application read the program and write the functionality of the program
for example
this is the input program and the application should read and describe the functionality of the program


bool a = true;

if(a=true)
{
  console.writeline("a is true");
}

else
{
   console.writeline("a is false");

}

output description:

the program includes the variable of boolean data type and if else statement .the body of if statement includes a message.the body of else includes a message.




i am new in c#,,,thanks in advance
Posted
Updated 8-May-14 23:29pm
v3
Comments
Richard MacCutchan 9-May-14 5:07am    
Thanks for what? you forgot to ask a question.
Adi5555 9-May-14 5:26am    
sorry i have updated the question
Richard MacCutchan 9-May-14 6:04am    
What you are describing, is a source code parser, which is not a trivial project. I think that as someone who is new to C# this may be too advanced for you. I suggest you concentrate on studying C# in more detail before trying to tackle something like this.
Adi5555 9-May-14 6:09am    
but this is my semester project...i have to do this ! can u suggest me how to start this project
Richard MacCutchan 9-May-14 6:22am    
I already suggested how to start. Once you are comfortable that you have a good understanding of C# and the .NET classes, then you can go to the next step.

So you want to write a source code parser. The first thing to do is create some sort of look-up table with all the keywords for the language you are going to process, including special characters, comments etc. Then for each keyword you need a set of rules that specify all the different ways that keyword can be written and what specific types of data may follow it. Then you can start writing the code to read each word in the source file, building up complete statements. Then when you have a complete statement you can parse it into its component parts and figure out exactly what it means. Once you have that information you can write the details to your output report. Repeat this process until you have consumed all the source file.

1 solution

Have a look:

If else, switch case
 
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