/* Demonstrates Bison C++ complete interface see Bison 10.1.6.2 Complete Symbols */
/* Compile: reflex --flex --bison-complete --bison-locations --reentrant flexexample11.lxx */
/* Compile: bison -d reflexexample11.yxx */

%top{
#include "parser.hpp"    /* Generated by bison. */
#include "location.hpp"  /* Generated by bison %locations. */
}

%class{
 public:
  std::map<std::string,double> map;
}

%option bison-complete
%option bison-cc-namespace=yy
%option bison-cc-parser=parser
%option bison-locations
%option reentrant

/* throw an exception in the scanner's default rule */
%option exception="yy::parser::syntax_error(location(), \"Unknown token.\")"

%option tabs=8

%option namespace=yy
%option lexer=scanner
%option outfile=scanner.cpp
%option header-file=scanner.hpp

%option fast
%option flex

var     [A-Za-z_][A-Za-z0-9_]*
exp     [Ee][-+]?[0-9]+
num     [0-9]*([0-9]|\.[0-9]|[0-9]\.)[0-9]*{exp}?

%%

\s          // ignore space
\"[^"]*\"   { return yy::parser::make_STR(yytext, location()); }
{var}       { return yy::parser::make_VAR(yytext, location()); }
{num}       { return yy::parser::make_NUM(strtod(yytext, NULL), location()); }
[-+*/=();]  { return yy::parser::symbol_type(*yytext, location()); }
<<EOF>>     { return yy::parser::make_EOF(location()); }

%%
