/* SI 413 Fall 2018
 * Unit 5 (Semantic Analysis)
 * This is the scanner for the "beefed up calculator" language.
 */

%{
#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); }
%%