lilypond-0.1.33
[lilypond.git] / src / symtable.cc
blobd55e9ac59bdd977572423dc035259af53d89ddad
1 #include "misc.hh"
2 #include "dimen.hh"
3 #include "debug.hh"
4 #include "real.hh"
5 #include "symbol.hh"
6 #include "assoc.hh"
7 #include "assoc-iter.hh"
8 #include "symtable.hh"
10 Symtables::Symtables()
14 Symtables::Symtables(Symtables const &s)
16 for (Assoc_iter<String, Symtable*> i(s); i.ok(); i++) {
17 add(i.key(), new Symtable(*i.val()));
21 Symtables::~Symtables()
23 for (Assoc_iter<String, Symtable*> i(*this); i.ok(); i++) {
24 delete i.val();
28 Symbol
29 Symtable::lookup(String s) const
31 if (elt_query(s))
32 return (*this)[s];
33 else {
34 error( "Unknown symbol `" +s+"'\n");
36 Symbol sy; // unreachable
37 return sy;
40 Symtable*
41 Symtables::operator()(String s)
43 return Assoc<String, Symtable*>::operator[](s);
45 void
46 Symtables::print() const
48 for (Assoc_iter<String, Symtable*> i(*this); i.ok(); i++) {
49 mtor << "table \'" << i.key() << "\' {\n";
50 i.val()->print();
51 mtor << "}\n";
54 void
55 Symtable::print() const
57 for (Assoc_iter<String, Symbol> i(*this); i.ok(); i++) {
58 mtor << "\'" << i.key() << "\'->" << i.val().str() << "\n";