2 symtable.cc -- implement Symbol_table
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
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
47 warning ("Symtable `" + id_str+ _("\': unknown symbol `") +s+"'\n");
54 Symtables::operator()(String s)
58 error ("Symtable `" + s + _("\' unknown"));
60 We can't return, because we'll dump core anyway.
65 return Dictionary<Symtable*>::operator[](s);
68 Symtables::print() const
70 for (Assoc_iter<String, Symtable*> i (*this); i.ok(); i++)
72 DOUT << "table \'" << i.key() << "\' {\n";
78 Symtable::print() const
80 for (Assoc_iter<String, Atom> i (*this); i.ok(); i++)
82 DOUT << "\'" << i.key() << "\'->" << i.val ().str () << "\n";
87 Symtables::add (String s, Symtable*p)
90 Dictionary<Symtable*>::add (s,p);