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]*
16 # define YY_USER_ACTION yylloc->columns (yyleng);
18 {blank}+ yylloc->step ();
19 [\n]+ yylloc->lines (yyleng); yylloc->step ();
21 [-+*/] return yytext[0];
22 ":=" return TOKEN_ASSIGN;
23 {int} yylval->ival = atoi (yytext); return TOKEN_NUMBER;
24 {id} yylval->sval = new std::string (yytext); return TOKEN_IDENTIFIER;
25 . driver.error (*yylloc, "invalid character");
29 calcxx_driver::scan_begin ()
31 yy_flex_debug = trace_scanning;
32 if (!(yyin = fopen (file.c_str (), "r")))
33 error (std::string ("cannot open ") + file);
37 calcxx_driver::scan_end ()