Skip to main content
gamedev.net
🔒 Locked

Flex problems

Started by danne89 0 replies 500+ views
Original Post
danne89
danne89
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
http://www.cis.gsu.edu/~shong/oojokes/
255
255
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.