#include "symtable.hh"
#include "const.hh"
+static Symbol unknown;
+
+
+// scary! What if Symtable resizes on the fly...?
+const Symbol *
+Symtable::lookup(String s) const
+{
+ if (elt_query(s))
+ return &(*this)[s];
+ else {
+ WARN<<"Unknown symbol " << s <<'\n';
+ return &unknown;
+ }
+}
Symtable*
Symtables::operator()(String s)
const Symbol*
-Symbol::find_ball(int i)
+Symbol::find_ball(int j)
{
- int j = intlog2(i)+1;
if (j > 4) j = 4;
Symtable * st = the_sym_tables("balls");
- return &(*st)[String(j)];
-
+ return st->lookup(String(j));
}
const Symbol*
-Symbol::find_rest(int i)
+Symbol::find_rest(int j)
{
- int j = intlog2(i)+1;
- return &(*the_sym_tables("rests"))[String(j)];
+ return the_sym_tables("rests")->lookup(String(j));
}
const Symbol*
Symbol::find_bar(String s)
{
- return &(*the_sym_tables("bars"))[s];
+ return the_sym_tables("bars")->lookup(s);
}
/****************************************************************/
// bare bones.
#include "glob.hh"
+#include "debug.hh"
#include "string.hh"
#include "keyword.hh"
#include "parser.hh"
"rhythmstaff", RHYTHMSTAFF,
"score", SCORE,
"bar", BAR,
+ "output", OUTPUT,
0,0
} ;
return table.lookup(s);
}
+Assoc<String, Identifier*> the_id_tab;
+
Identifier*
lookup_identifier(String s)
{
- assert(false);
- return 0;
+ if (!the_id_tab.elt_query(s))
+ the_id_tab[s]= new Identifier;
+
+ return the_id_tab[s];
}