title: tokenizing ints vs floats in lex/flex
body: <p>I'm teaching myself a little flex/bison for fun. I'm writing an interpreter for the 1975 version of MS Extended BASIC (Extended as in "has strings"). I'm slightly stumped by one issue though.</p>
  
  <p>Floats can be identified by looking for a <code>.</code> or an <code>E</code> (etc), and then fail over to an int otherwise. So I did this...</p>
  
  <pre><code>[0-9]*[0-9.][0-9]*([Ee][-+]?[0-9]+)? {
                        yylval.d = atof(yytext);
                        return FLOAT;
                      }
  [0-9]+ {
                        yylval.i = atoi(yytext);
                        return INT;
                      }
  </code></pre>
  
  <p>sub-fields in the yylval union are .d for double, .i for int and .s for string.</p>
  
  <p>But it is also possible that you need to use a float because the number is too large to store in an int - which in this case is a 16-bit signed.</p>
  
  <p>Is there a way to do this in the regex? Or do I have to do this in the associated c-side code with an if?</p>