3 # include "calc++-driver.hh"
4 # include "calc++-parser.hh"
7 %option noyywrap nounput batch debug
9 id [a-zA-Z][a-zA-Z_0-9]*
14 # define YY_USER_ACTION yylloc->columns (yyleng);
20 {blank}+ yylloc->step ();
21 [\n]+ yylloc->lines (yyleng); yylloc->step ();
23 [-+*/] return yytext[0];
24 ":=" return TOKEN_ASSIGN;
25 {int} yylval->ival = atoi (yytext); return TOKEN_NUMBER;
26 {id} yylval->sval = new std::string (yytext); return TOKEN_IDENTIFIER;
27 . driver.error (*yylloc, "invalid character");
31 calcxx_driver::scan_begin ()
33 yy_flex_debug = trace_scanning;
34 if (!(yyin = fopen (file.c_str (), "r")))
35 error (std::string ("cannot open ") + file);
39 calcxx_driver::scan_end ()