%{ #include #include "../include/rt_fix.h" #include "fixcalc.tab.h" %} natural [0-9]+ reel (([0-9]+[.][0-9]*)|([.][0-9]+))([eE][-+]?[0-9]+)? %option yylineno %% [ \t]+ ; /* discard whitespaces */ \n { return(NEWLINE); } {natural} { rt_fix_init_l(&yylval.number, strtol(yytext, NULL, 10)); return(NUMBER); } {reel} { rt_fix_init_d(&yylval.number, strtod(yytext, NULL)); return(NUMBER); } "+" { return(ADD); } "-" { return(SUB); } "*" { return(MUL); } "/" { return(DIV); } "(" { return(OPEN); } ")" { return(CLOSE); } "sqrt" { return(SQRT); } "exp" { return(EXP); } "sin" { return(SIN); } "asin" { return(ASIN); } "cos" { return(COS); } "acos" { return(ACOS); } "tan" { return(TAN); } "round" { return(ROUND); } "floor" { return(FLOOR); } "ceil" { return(CEIL); } "frac" { return(FRAC); } "abs" { return(ABS); } . { strncpy(yylval.string, yytext, sizeof(yylval.string)); yylval.string[sizeof(yylval.string) - 1] = '\0'; return(NOTHING); } %% int yywrap() { ; }