From: fred Date: Fri, 11 Oct 1996 19:55:49 +0000 (+0000) Subject: lilypond-0.0.3 X-Git-Tag: release/1.5.59~7095 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c34a522e6cb422ae756eac0d49fad26dac965b5b;p=lilypond.git lilypond-0.0.3 --- diff --git a/identifier.cc b/identifier.cc new file mode 100644 index 0000000000..9eab42e114 --- /dev/null +++ b/identifier.cc @@ -0,0 +1,22 @@ +#include +#include "keyword.hh" +#include "lexer.hh" +#include "parser.hh" + +Identifier::Identifier() +{ + data = 0; + type = IDENTIFIER; +} + + +Identifier::~Identifier() +{ + if (!data) + return; + switch (type) { + case IDENTIFIER: + default: + assert(false); + } +} diff --git a/keyword.hh b/keyword.hh index aa87a8dc1a..42267ef57a 100644 --- a/keyword.hh +++ b/keyword.hh @@ -13,5 +13,11 @@ struct Keyword_table int lookup(const char *s) const; }; -struct Identifier{ +struct Identifier +{ + void *data; + int type; + + Identifier(); + ~Identifier(); }; diff --git a/symtable.cc b/symtable.cc index 8b87e2fc99..5d295d0be5 100644 --- a/symtable.cc +++ b/symtable.cc @@ -6,6 +6,20 @@ #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) @@ -53,25 +67,22 @@ Symtables the_sym_tables("symbol.ini"); 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. diff --git a/table.cc b/table.cc index 45e6f4a0e4..b06e2ee92f 100644 --- a/table.cc +++ b/table.cc @@ -1,4 +1,5 @@ #include "glob.hh" +#include "debug.hh" #include "string.hh" #include "keyword.hh" #include "parser.hh" @@ -8,6 +9,7 @@ static Keyword_ent the_key_tab[]={ "rhythmstaff", RHYTHMSTAFF, "score", SCORE, "bar", BAR, + "output", OUTPUT, 0,0 } ; @@ -19,9 +21,13 @@ lookup_keyword(String s) return table.lookup(s); } +Assoc 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]; }