1 %{
 2 /* We usually need these... */
 3 #include <stdio.h>
 4 #include <stdlib.h>
 5 
 6 /* Include this to use yylex_destroy for flex version < 2.5.
 7 9 */
 8 #include "flex_memory_fix.h"
 9 
10 /* This is required and is generated automatically by bison 
11 from the .y file */
12 #include "y.tab.h"
13 
14 /* Local stuff we need here... */
15 #include <math.h>
16 extern double vbltable[26];
17 %}
18 
19 /* Add this to get line numbers... */
20 %option yylineno
21 
22 %%
23 ([0-9]+|([0-9]*\.[0-9]+)([eE][-+]?[0-9]+)?) {
24   yylval.dval = atof(yytext); return NUMBER;
25   }
26 
27 [ \t] ;    /* ignore white space */
28 
29 [a-z] { yylval.vblno = yytext[0] - 'a'; return NAME; }
30 
31 "$" { return 0; /* end of input */ }
32 
33 \n  |
34 . return yytext[0];
35 %%
36 
37 /* We need to add a main() function. 
38  * It is more convenient to put it here to manage flex 
39  memory management issues.
40  * At the minimum it must call yyparse().
41  */
42 extern int yyparse();
43 
44 int main(int argc, char *argv[])
45 {
46   printf("Enter sums using + - * / and () or type $ to quit.
47          \n");
48   yyparse();  /* REQUIRED */
49   yylex_destroy();  /* Add to clean up memory leaks */
50 }