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
++);
27 qsort (table
, maxkey
, sizeof (Keyword_ent
), tabcmp
);
31 lookup with binsearch, return tokencode.
34 Keyword_table::lookup (char const *s
) const
48 result
= strcmp (s
, table
[cmp
].name
);
56 if (!strcmp (s
, table
[lo
].name
))
58 return table
[lo
].tokcode
;
61 return -1; /* not found */