/******************************************************** * calc.lpp * SI 413 Fall 2011 * Lab 3 * Flex file specifying the calculator program scanner * * YOUR NAME HERE * YOUR PARTNER'S NAME HERE ********************************************************/ %{ #include "calc.tab.hpp" #include <iostream> using namespace std; %} %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); } %%