Nitpick run.
[lilypond/patrick.git] / lily / keyword.cc
blob70c84e59e2a6bfc9719f08dd62d41a171ba51444
1 /*
2 keyword.cc -- keywords and identifiers
3 */
5 #include "keyword.hh"
7 #include <cstring>
8 #include <cstdlib>
10 /* for qsort */
11 int tabcmp (Keyword_ent const &p1, Keyword_ent const &p2)
13 return strcmp (p1.name_, p2.name_);
16 Keyword_table::Keyword_table (Keyword_ent *tab)
18 while (tab->name_)
19 table_.push (*tab++);
21 table_.sort (tabcmp);
24 int
25 Keyword_table::lookup (char const *s) const
27 Keyword_ent e;
28 e.name_ = s;
29 int idx = binary_search (table_, e, tabcmp);
30 if (idx >= 0)
31 return table_[idx].tokcode_;
32 else
33 return -1;