]> git.saurik.com Git - bison.git/blob - examples/calc++/calc++-driver.hh
Start a set of simple examples.
[bison.git] / examples / calc++ / calc++-driver.hh
1 #ifndef CALCXX_DRIVER_HH
2 # define CALCXX_DRIVER_HH
3 # include <string>
4 # include <map>
5
6 /// Forward declarations.
7 union YYSTYPE;
8
9 namespace yy
10 {
11 class calcxx_parser;
12 class location;
13 }
14
15 class calcxx_driver;
16
17 // Announce to Flex the prototype we want for lexing function, ...
18 # define YY_DECL \
19 int yylex (YYSTYPE* yylval, yy::location* yylloc, calcxx_driver& driver)
20 // ... and declare it for the parser's sake.
21 YY_DECL;
22
23 /// Conducting the whole scanning and parsing of Calc++.
24 class calcxx_driver
25 {
26 public:
27 calcxx_driver ();
28 virtual ~calcxx_driver ();
29
30 /// The variables.
31 std::map<std::string, int> variables;
32
33 /// \name Handling the scanner.
34 /// \{
35 /// Open \a file for scanning.
36 void scan_begin ();
37 /// End scanning, clean up memory.
38 void scan_end ();
39 /// Whether to enable scanner traces.
40 bool trace_scanning;
41 /// \}
42
43 /// \name Handling the parser.
44 /// \{
45 /// Parse the file \a f.
46 void parse (const std::string& f);
47 /// The file being parsed.
48 std::string file;
49 /// Whether to enable parsing traces.
50 bool trace_parsing;
51 /// \}
52
53 /// The result.
54 int result;
55
56 /// \name Error handling.
57 /// \{
58 /// Register a located error.
59 void error (const yy::location& l, const std::string& m);
60 /// Register an error.
61 void error (const std::string& m);
62 /// \}
63 };
64 #endif