2 keyword.cc -- keywords and identifiers
7 #include "my-lily-lexer.hh"
12 tabcmp (void const * p1, void const * p2)
14 return strcmp (((Keyword_ent const *) p1)->name,
15 ((Keyword_ent const *) p2)->name);
18 Keyword_table::Keyword_table (Keyword_ent *tab)
23 for (maxkey = 0; table[maxkey].name; maxkey++);
26 qsort (table, maxkey, sizeof (Keyword_ent), tabcmp);
30 lookup with binsearch, return tokencode.
33 Keyword_table::lookup (char const *s) const
47 result = strcmp (s, table[cmp].name);
55 if (!strcmp (s, table[lo].name))
57 return table[lo].tokcode;
60 return -1; /* not found */