%{ /* * exp.l is the flex specification for * exp.y++. The exp.tab.h++ will be generated * bison (yacc) compiler. Compile as * $ flex exp.l * output: lex.yy.c */ #include #include #include "exp.tab.h" /* Generated by bison */ /* Copied verbatim in lex.yy.c */ %} %option noyywrap DELIM ([ \t]) WHITESPACES ({DELIM}+) NATNUM ([0-9]+) FLOAT (([0-9]*\.[0-9]+)|([0-9]+\.[0-9]*)) %% {WHITESPACES} { ; } {NATNUM} { yylval.integer = atoi(yytext) ; return INT ; } {FLOAT} { yylval.real = (float)atof(yytext) ; return FLOAT ; } "+" { return (int)'+' ; } "-" { return (int)'-' ; } "/" { return (int)'/' ; } "*" { return (int)'*' ;} "\n" { return (int)'\n';} "(" { return (int)'(';} ")" { return (int)')';} %% /* No C code */