Reputation: 119
I have a lex program as follows. I encounter the error
EOF encountered inside an action LEX program
%{
#include<stdio.h>
#include<math.h>
#include "y.tab.h"
%}
%%
[ \t]+ ;
[0-9]+ {yylval = atoi(yytext);
return INTEGER;}
[-+*/] {return *yytext;}
"(" {return *yytext;}
")" {return *yytext;}
\n {return *yytext;}
. {char msg[25];
sprintf(msg,"%s <%s>","invalid character",yytext);
yyerror(msg);}
Can someone help me out?
Upvotes: 0
Views: 4570
Reputation: 5893
This error often occurs if you have an EOF at the end of the text without terminating the last line with an end-of-line, but it can also be system dependent, making it hard to reproduce on other systems.
Ensure there is a blank line after the last line and the error is likely to go away.
Upvotes: 5