/* Demonstrates Bison C++ complete interface see Bison 10.1.6.2 Complete Symbols */
/* Compile: reflex --bison-complete --bison-locations reflexexample11.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::wstring,double> map;
}

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

/* 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 unicode
%option freespace

var     \p{UnicodeIdentifierStart} \p{UnicodeIdentifierPart}*
exp     [Ee] [-+]? \d+
num     \d* (\d | \.\d | \d\.) \d* {exp}?

%%

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

%%
