Debian Codegraph @

examples/c++/calc++/driver.hh

raw
1 /* Driver for calc++. -*- C++ -*-
2
3 Copyright (C) 2005-2015, 2018-2021 Free Software Foundation, Inc.
4
5 This file is part of Bison, the GNU Compiler Compiler.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20 #ifndef DRIVER_HH
21 # define DRIVER_HH
22 # include <string>
23 # include <map>
24 # include "parser.hh"
25
26 // Give Flex the prototype of yylex we want ...
27 # define YY_DECL \
28 yy::parser::symbol_type yylex (driver& drv)
29 // ... and declare it for the parser's sake.
30 YY_DECL;
31
32 // Conducting the whole scanning and parsing of Calc++.
33 class driver
34 {
35 public:
36 driver ();
37
38 std::map<std::string, int> variables;
39
40 int result;
41
42 // Run the parser on file F. Return 0 on success.
43 int parse (const std::string& f);
44 // The name of the file being parsed.
45 std::string file;
46 // Whether to generate parser debug traces.
47 bool trace_parsing;
48
49 // Handling the scanner.
50 void scan_begin ();
51 void scan_end ();
52 // Whether to generate scanner debug traces.
53 bool trace_scanning;
54 // The token's location used by the scanner.
55 yy::location location;
56 };
57 #endif // ! DRIVER_HH