K
K.Z.Zamli
Consider the following C code:
------------------------------
#include <stdio.h>
#include <string.h>
void InitTokenString(char InputStr[512]);
static char TokenString[100][100];
int length=0;
void main ()
{
char input1[100]="System.out.println (\"Hello\");";
char input2[100]="public void method1 (int x);";
InitTokenString(input1);
for (int i=0;i<length;i++)
{
printf ("%s\n",TokenString);
}
// pause to see the output
int ch=getch();
}
/* Tokenize TokenString & Initialize Length*/
void InitTokenString(char InputStr[512])
{
char *str;
int index=0;
str = strtok(InputStr," ");
strcpy (TokenString[index],str);
while (1)
{
str = strtok(NULL," ");
/* check if there is nothing else to extract */
if (str == NULL)
{
break;
}
else
{
index++;
strcpy (TokenString[index],str);
}
}
length=++index;
}
------------------------------
I am trying to search a string for a Java function definition using
C.
I've already manage to tokenize the string into a number of tokens.
How can I search the function from the string effectively because
there are so much possibilities: Consider these possibilities:
- public void method ( ) // space after 'method'
- public void method( ) // no space after 'method'
- public void m.method() // a '.' before method so this is a function
call in Java
- public void method (); // a semicolon after ')'
Any help is really appreciated...
------------------------------
#include <stdio.h>
#include <string.h>
void InitTokenString(char InputStr[512]);
static char TokenString[100][100];
int length=0;
void main ()
{
char input1[100]="System.out.println (\"Hello\");";
char input2[100]="public void method1 (int x);";
InitTokenString(input1);
for (int i=0;i<length;i++)
{
printf ("%s\n",TokenString);
}
// pause to see the output
int ch=getch();
}
/* Tokenize TokenString & Initialize Length*/
void InitTokenString(char InputStr[512])
{
char *str;
int index=0;
str = strtok(InputStr," ");
strcpy (TokenString[index],str);
while (1)
{
str = strtok(NULL," ");
/* check if there is nothing else to extract */
if (str == NULL)
{
break;
}
else
{
index++;
strcpy (TokenString[index],str);
}
}
length=++index;
}
------------------------------
I am trying to search a string for a Java function definition using
C.
I've already manage to tokenize the string into a number of tokens.
How can I search the function from the string effectively because
there are so much possibilities: Consider these possibilities:
- public void method ( ) // space after 'method'
- public void method( ) // no space after 'method'
- public void m.method() // a '.' before method so this is a function
call in Java
- public void method (); // a semicolon after ')'
Any help is really appreciated...