*** empty log message ***
[lilypond.git] / lily / keyword.cc
blobde6aca9e495cd7a6c6496384a0c3d7e2d6b377ca
1 /*
2 keyword.cc -- keywords and identifiers
3 */
4 #include <string.h>
5 #include <stdlib.h>
6 #include "keyword.hh"
9 /* for qsort */
10 int tabcmp (Keyword_ent const &p1, Keyword_ent const &p2)
12 return strcmp (p1.name_, p2.name_);
15 Keyword_table::Keyword_table (Keyword_ent *tab)
17 while (tab->name_)
19 table_.push (*tab++);
22 table_.sort (tabcmp);
25 int
26 Keyword_table::lookup (char const *s) const
28 Keyword_ent e ;
29 e.name_ = s;
30 int idx = binary_search (table_, e, tabcmp);
31 if (idx >= 0)
32 return table_[idx].tokcode_;
33 else
34 return -1;