]> git.draconx.ca Git - cdecl99.git/blobdiff - src/keywords.gperf
libcdecl: Avoid duplicating keyword strings w/ gperf.
[cdecl99.git] / src / keywords.gperf
index 88b2476d591e22d41bf726136efe67b788bb284d..22566aa8b84936183195087b6e4927e368addef3 100644 (file)
 static const struct keyword *in_word_set();
 %}
 
-%struct-type
 %readonly-tables
 %language=ANSI-C
-%global-table
-%pic
+
+/* Note: the following options enable gperf-wordwrap.awk to do its thing */
+%define word-array-name wordlist_wrapped
+%null-strings
+%struct-type
 
 struct keyword {
-       int_least16_t  name;
        uint_least8_t token;
 };
 %%
@@ -88,3 +89,16 @@ int cdecl__to_keyword(const char *s, int len, int english_mode)
 
        return T_IDENT;
 }
+
+static const char *wordlist_func(const struct keyword *k)
+{
+       unsigned x = k->token & 0x7f;
+
+       if (!x)
+               return NULL;
+
+       if (T_VOID >= 256)
+               x += 256;
+
+       return cdecl__token_name(x);
+}