]>
Commit | Line | Data |
---|---|---|
1c59e0a1 | 1 | %{ /* -*- C++ -*- */ |
0ffd4fd1 | 2 | # include <string> |
0ffd4fd1 AD |
3 | # include "calc++-driver.hh" |
4 | # include "calc++-parser.hh" | |
5 | %} | |
6 | ||
1c59e0a1 | 7 | %option noyywrap nounput batch debug |
0ffd4fd1 AD |
8 | |
9 | id [a-zA-Z][a-zA-Z_0-9]* | |
10 | int [0-9]+ | |
11 | blank [ \t] | |
12 | ||
828c373b AD |
13 | %{ |
14 | # define YY_USER_ACTION yylloc->columns (yyleng); | |
15 | %} | |
0ffd4fd1 | 16 | %% |
0ffd4fd1 | 17 | %{ |
0ffd4fd1 AD |
18 | yylloc->step (); |
19 | %} | |
20 | {blank}+ yylloc->step (); | |
21 | [\n]+ yylloc->lines (yyleng); yylloc->step (); | |
22 | ||
0ffd4fd1 AD |
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"); | |
0ffd4fd1 AD |
28 | %% |
29 | ||
30 | void | |
31 | calcxx_driver::scan_begin () | |
32 | { | |
33 | yy_flex_debug = trace_scanning; | |
34 | if (!(yyin = fopen (file.c_str (), "r"))) | |
35 | error (std::string ("cannot open ") + file); | |
36 | } | |
37 | ||
38 | void | |
39 | calcxx_driver::scan_end () | |
40 | { | |
41 | fclose (yyin); | |
42 | } |