title: failed to parse number by yacc and lex
body: <p>i have finished my lex file and start to learn about yacc
  but i have some question about part of my code of lex:</p>
  
  <pre><code>%{
  #include "y.tab.h"
  int num_lines = 1;
  int comment_mode=0;
  int stack =0;
  %}
  digit ([0-9])
  integer ({digit}+)
  float_num ({digit}+\.{digit}+)
  %%
  {integer} {  //deal with integer 
                  printf("#%d: NUM:",num_lines); ECHO;printf("\n");
                  yylval.Integer = atoi(yytext);
                  return INT;
                 }
  {float_num} {// deal with float
                   printf("#%d: NUM:",num_lines);ECHO;printf("\n");
                   yylval.Float = atof(yytext);
                   return FLOAT;
                   }
  \n         { ++num_lines; }
  .          if(strcmp(yytext," "))ECHO;
  %%
  int yywrap() {
  return 1;
  }
  </code></pre>
  
  <p>every time i got an integer or a float i return the token and save it into yylval
  and here is my code in parser.y:</p>
  
  <pre><code>%{
  #include &lt;stdio.h&gt;
  #define YYDEBUG 1  
  void yyerror (char const *s) {
  fprintf (stderr, "%s\n", s);
  }
  %}
  %union{
  int Integer;
  float Float;
  }
  %token &lt;int&gt;INT;
  %token &lt;float&gt;FLOAT;
  %%
  statement :
           INT  {printf("int yacc\n");}
        | FLOAT {printf("float yacc\n");}
        |
        ;
  %%
  int main(int argc, char** argv)
  {
  yyparse();
  return 0;
  }
  </code></pre>
  
  <p>which compiled by<br>
  byacc –d parser.y  </p>
  
  <p>lex lex.l  </p>
  
  <p>gcc lex.yy.c y.tab.c –ll  </p>
  
  <p>since i just want to try something easy to get started, i want to see if i can parse
  only int and float number first, i print them in both .l and .y file after i input an
  integer or a float.int the begining i input fisrt random number, for example 123
  , then my program  print :  </p>
  
  <blockquote>
    <p>1: NUM: 123</p>
  </blockquote>
  
  <p>in yylex() and  </p>
  
  <blockquote>
    <p>"int yacc\n"</p>
  </blockquote>
  
  <p>in parser.y<br>
  but if i input the second else number, it shows syntax error and the program shutdown
  i dont know where is the problem.
  is there any solution?</p>