2 keyword.cc -- keywords and identifiers
12 /* for the keyword table */
23 Keyword_table(Keyword_ent *);
24 int lookup(const char *s) const;
30 tabcmp(const void * p1, const void * p2)
32 return strcmp(((const Keyword_ent *) p1)->name,
33 ((const Keyword_ent *) p2)->name);
36 Keyword_table::Keyword_table(Keyword_ent *tab)
41 for (maxkey = 0; table[maxkey].name; maxkey++);
44 qsort(table, maxkey, sizeof(Keyword_ent), tabcmp);
48 lookup with binsearch, return tokencode.
51 Keyword_table::lookup(const char *s)const
65 result = strcmp(s, table[cmp].name);
73 if (!strcmp(s, table[lo].name))
75 return table[lo].tokcode;
77 return -1; /* not found */