2 keyword.cc -- keywords and identifiers
13 tabcmp (void const * p1, void const * p2)
15 return strcmp (((Keyword_ent const *) p1)->name,
16 ((Keyword_ent const *) p2)->name);
19 Keyword_table::Keyword_table (Keyword_ent *tab)
24 for (maxkey = 0; table[maxkey].name; maxkey++)
28 qsort (table, maxkey, sizeof (Keyword_ent), tabcmp);
32 lookup with binsearch, return tokencode.
35 Keyword_table::lookup (char const *s) const
49 result = strcmp (s, table[cmp].name);
57 if (!strcmp (s, table[lo].name))
59 return table[lo].tokcode;
62 return -1; /* not found */