Move enum xkb_file_type to xkbcomp/ast.h
[platform/upstream/libxkbcommon.git] / src / xkbcomp / ast.h
1 /************************************************************
2  * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
3  *
4  * Permission to use, copy, modify, and distribute this
5  * software and its documentation for any purpose and without
6  * fee is hereby granted, provided that the above copyright
7  * notice appear in all copies and that both that copyright
8  * notice and this permission notice appear in supporting
9  * documentation, and that the name of Silicon Graphics not be
10  * used in advertising or publicity pertaining to distribution
11  * of the software without specific prior written permission.
12  * Silicon Graphics makes no representation about the suitability
13  * of this software for any purpose. It is provided "as is"
14  * without any express or implied warranty.
15  *
16  * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18  * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19  * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
23  * THE USE OR PERFORMANCE OF THIS SOFTWARE.
24  *
25  ********************************************************/
26
27 #ifndef XKBCOMP_AST_H
28 #define XKBCOMP_AST_H
29
30 enum xkb_file_type {
31     /* Component files, by order of compilation. */
32     FILE_TYPE_KEYCODES = 0,
33     FILE_TYPE_TYPES = 1,
34     FILE_TYPE_COMPAT = 2,
35     FILE_TYPE_SYMBOLS = 3,
36     /* Geometry is not compiled any more. */
37     FILE_TYPE_GEOMETRY = 4,
38
39     /* A top level file which includes the above files. */
40     FILE_TYPE_KEYMAP,
41
42 /* File types which must be found in a keymap file. */
43 #define FIRST_KEYMAP_FILE_TYPE FILE_TYPE_KEYCODES
44 #define LAST_KEYMAP_FILE_TYPE  FILE_TYPE_SYMBOLS
45
46     /* This one doesn't mix with the others, but useful here as well. */
47     FILE_TYPE_RULES,
48
49     _FILE_TYPE_NUM_ENTRIES
50 };
51
52 enum stmt_type {
53     STMT_UNKNOWN = 0,
54     STMT_INCLUDE,
55     STMT_KEYCODE,
56     STMT_ALIAS,
57     STMT_EXPR,
58     STMT_VAR,
59     STMT_TYPE,
60     STMT_INTERP,
61     STMT_VMOD,
62     STMT_SYMBOLS,
63     STMT_MODMAP,
64     STMT_GROUP_COMPAT,
65     STMT_INDICATOR_MAP,
66     STMT_INDICATOR_NAME,
67
68     _STMT_NUM_VALUES
69 };
70
71 enum expr_value_type {
72     EXPR_TYPE_UNKNOWN = 0,
73     EXPR_TYPE_BOOLEAN,
74     EXPR_TYPE_INT,
75     EXPR_TYPE_STRING,
76     EXPR_TYPE_ACTION,
77     EXPR_TYPE_KEYNAME,
78     EXPR_TYPE_SYMBOLS,
79
80     _EXPR_TYPE_NUM_VALUES
81 };
82
83 enum expr_op_type {
84     EXPR_VALUE,
85     EXPR_IDENT,
86     EXPR_ACTION_DECL,
87     EXPR_FIELD_REF,
88     EXPR_ARRAY_REF,
89     EXPR_KEYSYM_LIST,
90     EXPR_ACTION_LIST,
91     EXPR_ADD,
92     EXPR_SUBTRACT,
93     EXPR_MULTIPLY,
94     EXPR_DIVIDE,
95     EXPR_ASSIGN,
96     EXPR_NOT,
97     EXPR_NEGATE,
98     EXPR_INVERT,
99     EXPR_UNARY_PLUS,
100
101     _EXPR_NUM_VALUES
102 };
103
104 enum merge_mode {
105     MERGE_DEFAULT,
106     MERGE_AUGMENT,
107     MERGE_OVERRIDE,
108     MERGE_REPLACE,
109 };
110
111 const char *
112 xkb_file_type_to_string(enum xkb_file_type type);
113
114 const char *
115 stmt_type_to_string(enum stmt_type type);
116
117 const char *
118 expr_op_type_to_string(enum expr_op_type type);
119
120 const char *
121 expr_value_type_to_string(enum expr_value_type type);
122
123 typedef struct _ParseCommon {
124     enum stmt_type type;
125     struct _ParseCommon *next;
126 } ParseCommon;
127
128 typedef struct _IncludeStmt {
129     ParseCommon common;
130     enum merge_mode merge;
131     char *stmt;
132     char *file;
133     char *map;
134     char *modifier;
135     struct _IncludeStmt *next_incl;
136 } IncludeStmt;
137
138 typedef struct _Expr {
139     ParseCommon common;
140     enum expr_op_type op;
141     enum expr_value_type value_type;
142     union {
143         struct {
144             struct _Expr *left;
145             struct _Expr *right;
146         } binary;
147         struct {
148             xkb_atom_t element;
149             xkb_atom_t field;
150         } field;
151         struct {
152             xkb_atom_t element;
153             xkb_atom_t field;
154             struct _Expr *entry;
155         } array;
156         struct {
157             xkb_atom_t name;
158             struct _Expr *args;
159         } action;
160         struct {
161             darray(char *) syms;
162             darray(int) symsMapIndex;
163             darray(unsigned int) symsNumEntries;
164         } list;
165         struct _Expr *child;
166         xkb_atom_t str;
167         unsigned uval;
168         int ival;
169         char keyName[XkbKeyNameLength];
170     } value;
171 } ExprDef;
172
173 typedef struct _VarDef {
174     ParseCommon common;
175     enum merge_mode merge;
176     ExprDef *name;
177     ExprDef *value;
178 } VarDef;
179
180 typedef struct _VModDef {
181     ParseCommon common;
182     enum merge_mode merge;
183     xkb_atom_t name;
184     ExprDef *value;
185 } VModDef;
186
187 typedef struct _KeycodeDef {
188     ParseCommon common;
189     enum merge_mode merge;
190     char name[XkbKeyNameLength];
191     unsigned long value;
192 } KeycodeDef;
193
194 typedef struct _KeyAliasDef {
195     ParseCommon common;
196     enum merge_mode merge;
197     char alias[XkbKeyNameLength];
198     char real[XkbKeyNameLength];
199 } KeyAliasDef;
200
201 typedef struct _KeyTypeDef {
202     ParseCommon common;
203     enum merge_mode merge;
204     xkb_atom_t name;
205     VarDef *body;
206 } KeyTypeDef;
207
208 typedef struct _SymbolsDef {
209     ParseCommon common;
210     enum merge_mode merge;
211     char keyName[XkbKeyNameLength];
212     ExprDef *symbols;
213 } SymbolsDef;
214
215 typedef struct _ModMapDef {
216     ParseCommon common;
217     enum merge_mode merge;
218     xkb_atom_t modifier;
219     ExprDef *keys;
220 } ModMapDef;
221
222 typedef struct _GroupCompatDef {
223     ParseCommon common;
224     enum merge_mode merge;
225     int group;
226     ExprDef *def;
227 } GroupCompatDef;
228
229 typedef struct _InterpDef {
230     ParseCommon common;
231     enum merge_mode merge;
232     char *sym;
233     ExprDef *match;
234     VarDef *def;
235 } InterpDef;
236
237 typedef struct _IndicatorNameDef {
238     ParseCommon common;
239     enum merge_mode merge;
240     int ndx;
241     ExprDef *name;
242     bool virtual;
243 } IndicatorNameDef;
244
245 typedef struct _IndicatorMapDef {
246     ParseCommon common;
247     enum merge_mode merge;
248     xkb_atom_t name;
249     VarDef *body;
250 } IndicatorMapDef;
251
252 typedef struct _XkbFile {
253     ParseCommon common;
254     enum xkb_file_type file_type;
255     char *topName;
256     char *name;
257     ParseCommon *defs;
258     int id;
259     unsigned flags;
260 } XkbFile;
261
262 #endif