%{ #include #include #include #include "calc-types.tab.h" char *dequote(const char *); %} %option noyywrap DIGIT [0-9] %% {DIGIT}+("."{DIGIT}*)? { yylval.zahl = atof(yytext); return NUMBER; } "\""[^"\n]*"\"" { yylval.string = dequote(yytext); return STRING; } "=" | "(" | ")" | "+" | "-" | "*" | "/" { return *yytext; } [[:space:]] { /* ignoriere Whitespace */ } . { return ILLEGAL_CHAR; } %% char *dequote(const char *s) { char *retVal; retVal = (char *) malloc(strlen(s)-2+1); strncpy(retVal, &(s[1]), strlen(s)-2); return retVal; }