views:

56

answers:

2

I want to take a program as input and I want to find out:

  1. No. of identifiers
  2. No. of unique lines containing identifiers
  3. No. of identifiers in the set of unique lines
  4. No. of inputs and outputs
  5. According to control structures in the program I want to assign a value to control structures

If I calculate this I can do my project. This is the basic for me.

Can any one help me with this by giving guidelines or anything? It's urgent, please! I am trying this but I am not getting anywhere.

For example:

#include<stdio.h>
void main()
{
    int a,b,c;
    float d;
    printf("enter a,b,c value");
    scanf("%d %d %d",&a,&b,&c);
    d=a+b+c;
    getch();
}

Through files I will take the above program as input and I want to count identifiers. For example:

  1. There are 4 identifiers (a, b, c, and d).
  2. No. of input is 1
  3. No. of output is 1

We can do this manually but I want to do the calculation in a program, how to count the identifiers, inputs, outputs, etc.

+2  A: 

Looks like you want to write a C parser in Java.

Take a look at JavaCC

codaddict
+1  A: 

Have a look at this thread : Java Programming - Parse "C" code using Java.

It talks about using

Lazer