7

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 following error

filename.l:16: EOF encountered inside an action

Can anybody see any error

1 Answers1

5

Your number pattern ([0-9]+) has an extra } in its action, which is confusing (and also confusing for flex).

rici
  • 234,347
  • 28
  • 237
  • 341