1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | %{ #include <iostream> #include <cstdlib> #include "bisoncalc.tab.hpp" using namespace std; YYSTYPE yylval; %} %option noyywrap %% [+-]?[0-9]+ { yylval.val = atoi(yytext); return NUM; } [+-] { yylval.sym = yytext[0]; return OPA; } [*/] { yylval.sym = yytext[0]; return OPM; } "(" { return LP; } ")" { return RP; } ";" { return STOP; } <<EOF>> { return 0; } [ \t\n]+ { } . { cerr << "Unrecognized token!" << endl; exit(1); } %% |