5 # include "calc++-driver.hh"
6 # include "calc++-parser.hh"
9 %option noyywrap nounput debug batch
11 id [a-zA-Z][a-zA-Z_0-9]*
18 # define YY_USER_ACTION yylloc->columns (yyleng);
21 {blank}+ yylloc->step ();
22 [\n]+ yylloc->lines (yyleng); yylloc->step ();
25 [-+*/] return yytext[0];
26 ":=" return TOKEN_ASSIGN;
27 {int} yylval->ival = atoi (yytext); return TOKEN_NUMBER;
28 {id} yylval->sval = new std::string (yytext); return TOKEN_IDENTIFIER;
29 . driver.error (*yylloc, "invalid character");
34 calcxx_driver::scan_begin ()
36 yy_flex_debug = trace_scanning;
37 if (!(yyin = fopen (file.c_str (), "r")))
38 error (std::string ("cannot open ") + file);
42 calcxx_driver::scan_end ()