So, the thing is I'm trying to do a lexical analyzer and I call it from a syntactical analyzer.
I have this:
int lexico(char linea[MAXLINEA])
{
if (linea[0] == '1') return 1;
else if (linea[0] == '2') return 2;
else if (linea[0] == '3') return 3;
else if (linea[0] == '4') return 4;
else return -1;
return 0;
}
int main(int argc, char *argv[])
{
...
FILE *fichero;
fich = fopen("test", "r");
...
int l;
char buffer[MAXLINEA];
while(fgets(buffer,MAXLINEA,fich) != NULL){
l = lexico(buffer);
...
}
}
This is just a poor example.
So imagine I have something in linea[1]
and, after the first return to main
, I want to return to lexico
and continue analyzing linea[1]
. Is it possible?
Thank you in advance.
PS: I know I can do this, for example, using Struct and saving several int values but I don't want to use it.