Modules |
Files |
Inheritance Tree |
Inheritance Graph |
Name Index |
Config
File: Synopsis/Parser/C++/syn/dict.hh
1| // Synopsis C++ Parser: dict.hh header file
2| // The Dictionary class which is used to store and lookup types for each scope
3|
4| // $Id: dict.hh,v 1.11 2002/11/17 12:11:43 chalky Exp $
5| //
6| // This file is a part of Synopsis.
7| // Copyright (C) 2002 Stephen Davies
8| //
9| // Synopsis is free software; you can redistribute it and/or modify it
10| // under the terms of the GNU General Public License as published by
11| // the Free Software Foundation; either version 2 of the License, or
12| // (at your option) any later version.
13| //
14| // This program is distributed in the hope that it will be useful,
15| // but WITHOUT ANY WARRANTY; without even the implied warranty of
16| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17| // General Public License for more details.
18| //
19| // You should have received a copy of the GNU General Public License
20| // along with this program; if not, write to the Free Software
21| // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22| // 02111-1307, USA.
23|
24| #ifndef H_SYNOPSIS_CPP_DICT
25| #define H_SYNOPSIS_CPP_DICT
26|
27| #include <vector>
28| #include <string>
29| #include "common.hh"
30|
31|
32| namespace Types
33| {
34| class Named;
35| }
36|
37|
38| namespace AST
39| {
40| class Declaration;
41| }
42|
43|
44|
45|
46|
47| class Dictionary : public cleanup
48| {
49| public:
50|
51| Dictionary();
52|
53| ~Dictionary();
54|
55|
56|
57| typedef std::vector<Types::Named*> Type_vector;
58|
59|
60|
61| struct MultipleError
62| {
63|
64|
65| Type_vector types;
66| };
67|
68|
69| struct KeyError
70| {
71|
72| KeyError(const std::string& n)
73| : name(n)
74| { }
75|
76| std::string name;
77| };
78|
79|
80| bool has_key(const std::string& name);
81|
82|
83|
84| Types::Named* lookup(const std::string& name);
85|
86|
87|
88|
89| Type_vector lookupMultiple(const std::string& name) throw (KeyError);
90|
91|
92|
93|
94| void insert(AST::Declaration* decl);
95|
96|
97|
98| void insert(Types::Named* named);
99|
100|
101| void dump();
102|
103|
104| private:
105| struct Data;
106|
107|
108| Data* m;
109| };
110|
111| #endif // header guard
112|