2 symtable.cc -- implement Symbol_table
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "dimension.hh"
15 #include "assoc-iter.hh"
16 #include "symtable.hh"
18 Symtables::Symtables()
23 Symtables::Symtables (Symtables const &s)
24 : Dictionary<Symtable*> (s)
26 for (Assoc_iter<String, Symtable*> i (s); i.ok(); i++)
28 add (i.key(), new Symtable (*i.val ()));
32 Symtables::~Symtables()
34 for (Assoc_iter<String, Symtable*> i (*this); i.ok(); i++)
41 Symtable::lookup (String s) const
50 warning (_f ("Symtable `%s\': unknown symbol: `%s\'", id_str, s));
57 Symtables::operator()(String s)
61 error (_f ("Symtable `%s\' unknown", s));
63 We can 't return, because we'll dump core anyway.
68 return Dictionary<Symtable*>::operator[](s);
71 Symtables::print() const
73 for (Assoc_iter<String, Symtable*> i (*this); i.ok(); i++)
75 DOUT << "table \'" << i.key () << "\' {\n";
81 Symtable::print() const
83 for (Assoc_iter<String, Atom> i (*this); i.ok(); i++)
85 DOUT << "\'" << i.key() << "\'->" << i.val ().str () << '\n';
90 Symtables::add (String s, Symtable*p)
93 Dictionary<Symtable*>::add (s,p);