%{ #include #include "calc.tab.h" #include "calculator.h" %} %option outfile="calc.yy.cpp" header-file="calc.yy.h" %option case-sensitive %option array D [0-9] E [Ee][+-]?{D}+ %% pi { return MATHPI; } sin { return FCESIN; } cos { return FCECOS; } exp { return FCEEXP; } log { return FCELOG; } [a-zA-Z]+ { yylval.svalue = strdup (yytext); return IDENT; } {D}+ { yylval.svalue = strdup (yytext); return INTEGER; } {D}*\.{D}+({E})? { yylval.svalue = strdup (yytext); return DOUBLE; } {D}*\.{D}*({E})? { yylval.svalue = strdup (yytext); return DOUBLE; } \{.*\} [ \t]+ /* ignored */ \n { return ENDLINE; } . { return yytext[0]; } %% void prevent_unused (void) { (void) yyunput; /* (void) input; */ }