Filename.l: 16: EOF occurs inside an action

I have a lex file like this

   %{
        #include "y.tab.h"
    %}

    %%
    "print"     {return print;}
    "exit"      {return exit_command;}
    [a-zA-Z]    {yylval.id = atoi(yytext); return identifier;}
    [0-9]+      {yylval.num = atoi(yytext);} return number;}
    [ \t\n]     ;
    [-+=;]      {return yytext[0];}
    .       {ECHO; yyerror("unexpected charater");}
    %%

    int yywrap(void){return 1;}

      

But when I try to run lex filename.l
I get the following error

filename.l:16: EOF encountered inside an action

      

Can anyone see the error

+3


source to share


1 answer


Your number pattern ( [0-9]+

) has an extra }

in its action, which is confusing (as well as confusing for flex

).



+3


source







All Articles