1%{
2#include "xkbcomp-priv.h"
3#include "parser-priv.h"
4
5static unsigned int
6keyword_gperf_hash(const char *str, unsigned int len);
7
8static const struct keyword_tok *
9keyword_gperf_lookup(const char *str, unsigned int len);
10%}
11
12struct keyword_tok { int name; int tok; };
13%language=ANSI-C
14%define hash-function-name keyword_gperf_hash
15%define lookup-function-name keyword_gperf_lookup
16%readonly-tables
17%enum
18%includes
19%struct-type
20%pic
21%ignore-case
22
23%%
24action,                 ACTION_TOK
25alias,                  ALIAS
26alphanumeric_keys,      ALPHANUMERIC_KEYS
27alternate_group,        ALTERNATE_GROUP
28alternate,              ALTERNATE
29augment,                AUGMENT
30default,                DEFAULT
31function_keys,          FUNCTION_KEYS
32group,                  GROUP
33hidden,                 HIDDEN
34include,                INCLUDE
35indicator,              INDICATOR
36interpret,              INTERPRET
37keypad_keys,            KEYPAD_KEYS
38key,                    KEY
39keys,                   KEYS
40logo,                   LOGO
41modifier_keys,          MODIFIER_KEYS
42modifier_map,           MODIFIER_MAP
43mod_map,                MODIFIER_MAP
44modmap,                 MODIFIER_MAP
45outline,                OUTLINE
46overlay,                OVERLAY
47override,               OVERRIDE
48partial,                PARTIAL
49replace,                REPLACE
50row,                    ROW
51section,                SECTION
52shape,                  SHAPE
53solid,                  SOLID
54text,                   TEXT
55type,                   TYPE
56virtual_modifiers,      VIRTUAL_MODS
57virtual,                VIRTUAL
58xkb_compatibility_map,  XKB_COMPATMAP
59xkb_compatibility,      XKB_COMPATMAP
60xkb_compat_map,         XKB_COMPATMAP
61xkb_compat,             XKB_COMPATMAP
62xkb_geometry,           XKB_GEOMETRY
63xkb_keycodes,           XKB_KEYCODES
64xkb_keymap,             XKB_KEYMAP
65xkb_layout,             XKB_LAYOUT
66xkb_semantics,          XKB_SEMANTICS
67xkb_symbols,            XKB_SYMBOLS
68xkb_types,              XKB_TYPES
69%%
70
71int
72keyword_to_token(const char *string, unsigned int len)
73{
74    const struct keyword_tok *kt = keyword_gperf_lookup(string, len);
75    if (!kt)
76        return -1;
77    return kt->tok;
78}
79