2 symtable.cc -- implement Symbol_table
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
15 #include "assoc-iter.hh"
16 #include "symtable.hh"
18 Symtables::Symtables()
22 Symtables::Symtables (Symtables
const &s
)
24 for (Assoc_iter
<String
, Symtable
*> i (s
); i
.ok(); i
++)
26 add (i
.key(), new Symtable (*i
.val ()));
30 Symtables::~Symtables()
32 for (Assoc_iter
<String
, Symtable
*> i (*this); i
.ok(); i
++)
39 Symtable::lookup (String s
) const
45 warning ("Symtable `" + id_str
+ _("\': unknown symbol `") +s
+"'\n");
52 Symtables::operator()(String s
)
56 error ("Symtable `" + s
+ _("\' unknown"));
58 We can't return, because we'll dump core anyway.
63 return Dictionary
<Symtable
*>::operator[](s
);
66 Symtables::print() const
68 for (Assoc_iter
<String
, Symtable
*> i (*this); i
.ok(); i
++)
70 DOUT
<< "table \'" << i
.key() << "\' {\n";
76 Symtable::print() const
78 for (Assoc_iter
<String
, Atom
> i (*this); i
.ok(); i
++)
80 DOUT
<< "\'" << i
.key() << "\'->" << i
.val ().str () << "\n";
85 Symtables::add (String s
, Symtable
*p
)
88 Dictionary
<Symtable
*>::add (s
,p
);