Sign in to follow this  

Flex problems

This topic is 4379 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I thought it would be nice to use GNU flex to read in my files. I was wrong. I'm expering some strange error. The program just crash. Here is the lex file:

%%

[0-9]..."-"[0-9]."-"[0-9].          SetCurrentTo(yytext);
"-"[0-9]+ 	SetCurrentTo(yytext);
[0-9]+          SetCurrentTo(yytext);
[0-9]+"."[0-9]+  SetCurrentTo(yytext);
"False"|"True" SetCurrentTo(yytext);

,  	 MoveAlong(); 
'\n'	 NextEntry();  
[ \t]+	 ;
.	PrintError(yytext); 
%%
int yywrap()
{
	printf("In yywrap");
	return 1;
}

And yylex() is called like:

....
	yyin = f;

	yylex();
	printf("Back!\n");a

	fclose(f);

	ParseFileName(mf, path);

	return 0;
}

My output is:
Comma
yytext = 1
Comma
yytext = True
Comma
yytext = 2005-12-22
Comma
yytext = 90
Comma
yytext = 60006232
Comma
yytext = 10000020
Comma
yytext = 30001669
Comma
yytext = 5
Comma

In yywrap
... and then it crash

Anyone got any thoughts about this? // Daniel Lännström

Share this post


Link to post
Share on other sites
I can't see any obvious errors there (except that printf("In yywrap"); is probably missing an "\n"). Maybe there is a memory access error somewhere. Where does the crash occur according to the debugger? Run your program through a memory checker like valgrind too if you have one.

Share this post


Link to post
Share on other sites
Sign in to follow this