%{ #include #include #include "parser.tab.h" %} %option noyywrap %% "+" {return PLUS;} "-" {return MINUS;} "/" {return DIVIDE;} "*" {return TIMES;} "(" {return LEFT;} ")" {return RIGHT;} [0-9]+ {yylval.value = atof(yytext); return VAL;} [0-9]+"."[0-9]+ {yylval.value = atof(yytext); return VAL;} [ \t] {} "\n" {return DONE;} "PI" {yylval.value = 3.14159265358979323; return VAL;} "E" {yylval.value = 2.718281828; return VAL;} . {printf("Error: invlaid lexeme '%s'.\n", yytext); return 0;} %%