Hi,
I have a homework to do for college, which asks me to write a pascal lexical analizer in C. I'm trying to figure out the best way to ignore the comments, so far I've written this code, which works, but I would like to know if there is an simpler way to do that, here is my code:
input = fopen("./arquivo.pas", "r");
while ((c = fgetc(input)) != EOF)
{
if (c == '{')
{
do
{
c = fgetc(input);
}
while (c != '}');
continue;
} else if (c == '/')
{
if (( c = fgetc(input) == '/'))
do{}while((c = fgetc(input)) != '\n');
else
{
printf("/");
fseek(input, -1, SEEK_CUR);
continue;
}
}
printf("%c", c);
}
Regards.