1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | /* SI 413 Fall 2011 * Class 12 * bcalc.lpp */ %{ #include <iostream> using namespace std; #include "parsetree.hpp" #include "bcalc.tab.hpp" %} %option noyywrap %% [0-9]+ { yylval = new ParseTree(yytext); return NUM; } [a-zA-Z]+ {yylval = new ParseTree(yytext); return VAR; } [+-] { yylval = new ParseTree(yytext); return OPA; } [*/] { yylval = new ParseTree(yytext); return OPM; } [><=] { yylval = new ParseTree(yytext); return COMP; } [&|] { yylval = new ParseTree(yytext); return BOP; } ":=" { yylval = new ParseTree(yytext); return ASN; } "(" { yylval = new ParseTree(yytext); return LP; } ")" { yylval = new ParseTree(yytext); return RP; } ";" { yylval = new ParseTree(yytext); return STOP; } <<EOF>> { return 0; } [ \t\n]+ { } . { cerr << "Unrecognized token!" << endl; exit(1); } %% |