Make parser and scanner reentrant
[platform/upstream/libxkbcommon.git] / src / xkbcomp / xkbcomp.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_H
28 #define XKBCOMP_H 1
29
30 #include "utils.h"
31
32 #include "xkbcommon/xkbcommon.h"
33 #include "XKBcommonint.h"
34 #include "xkbmisc.h"
35
36 #define TypeUnknown     0
37 #define TypeBoolean     1
38 #define TypeInt         2
39 #define TypeString      4
40 #define TypeAction      5
41 #define TypeKeyName     6
42 #define TypeSymbols     7
43
44 #define StmtUnknown             0
45 #define StmtInclude             1
46 #define StmtKeycodeDef          2
47 #define StmtKeyAliasDef         3
48 #define StmtExpr                4
49 #define StmtVarDef              5
50 #define StmtKeyTypeDef          6
51 #define StmtInterpDef           7
52 #define StmtVModDef             8
53 #define StmtSymbolsDef          9
54 #define StmtModMapDef           10
55 #define StmtGroupCompatDef      11
56 #define StmtIndicatorMapDef     12
57 #define StmtIndicatorNameDef    13
58
59 #define FileSymInterp   100
60
61 typedef struct _ParseCommon
62 {
63     unsigned stmtType;
64     struct _ParseCommon *next;
65 } ParseCommon;
66
67 #define ExprValue       0
68 #define ExprIdent       1
69 #define ExprActionDecl  2
70 #define ExprFieldRef    3
71 #define ExprArrayRef    4
72 #define ExprKeysymList  5
73 #define ExprActionList  6
74
75 #define OpAdd           20
76 #define OpSubtract      21
77 #define OpMultiply      22
78 #define OpDivide        23
79 #define OpAssign        24
80 #define OpNot           25
81 #define OpNegate        26
82 #define OpInvert        27
83 #define OpUnaryPlus     28
84
85 #define MergeDefault    0
86 #define MergeAugment    1
87 #define MergeOverride   2
88 #define MergeReplace    3
89 #define MergeAltForm    4
90
91 #define AutoKeyNames    (1L <<  0)
92 #define CreateKeyNames(x)       ((x)->flags&AutoKeyNames)
93
94 extern unsigned warningLevel;
95
96 typedef struct _IncludeStmt
97 {
98     ParseCommon common;
99     unsigned merge;
100     char *stmt;
101     char *file;
102     char *map;
103     char *modifier;
104     char *path;
105     struct _IncludeStmt *next;
106 } IncludeStmt;
107
108 typedef struct _Expr
109 {
110     ParseCommon common;
111     unsigned op;
112     unsigned type;
113     union
114     {
115         struct
116         {
117             struct _Expr *left;
118             struct _Expr *right;
119         } binary;
120         struct
121         {
122             xkb_atom_t element;
123             xkb_atom_t field;
124         } field;
125         struct
126         {
127             xkb_atom_t element;
128             xkb_atom_t field;
129             struct _Expr *entry;
130         } array;
131         struct
132         {
133             xkb_atom_t name;
134             struct _Expr *args;
135         } action;
136         struct
137         {
138             int nSyms;
139             int szSyms;
140             char **syms;
141         } list;
142         struct _Expr *child;
143         xkb_atom_t str;
144         unsigned uval;
145         int ival;
146         char keyName[5];
147     } value;
148 } ExprDef;
149
150 typedef struct _VarDef
151 {
152     ParseCommon common;
153     unsigned merge;
154     ExprDef *name;
155     ExprDef *value;
156 } VarDef;
157
158 typedef struct _VModDef
159 {
160     ParseCommon common;
161     unsigned merge;
162     xkb_atom_t name;
163     ExprDef *value;
164 } VModDef;
165
166 typedef struct _KeycodeDef
167 {
168     ParseCommon common;
169     unsigned merge;
170     char name[5];
171     unsigned long value;
172 } KeycodeDef;
173
174 typedef struct _KeyAliasDef
175 {
176     ParseCommon common;
177     unsigned merge;
178     char alias[5];
179     char real[5];
180 } KeyAliasDef;
181
182 typedef struct _KeyTypeDef
183 {
184     ParseCommon common;
185     unsigned merge;
186     xkb_atom_t name;
187     VarDef *body;
188 } KeyTypeDef;
189
190 typedef struct _SymbolsDef
191 {
192     ParseCommon common;
193     unsigned merge;
194     char keyName[5];
195     ExprDef *symbols;
196 } SymbolsDef;
197
198 typedef struct _ModMapDef
199 {
200     ParseCommon common;
201     unsigned merge;
202     xkb_atom_t modifier;
203     ExprDef *keys;
204 } ModMapDef;
205
206 typedef struct _GroupCompatDef
207 {
208     ParseCommon common;
209     unsigned merge;
210     int group;
211     ExprDef *def;
212 } GroupCompatDef;
213
214 typedef struct _InterpDef
215 {
216     ParseCommon common;
217     unsigned merge;
218     char *sym;
219     ExprDef *match;
220     VarDef *def;
221 } InterpDef;
222
223 typedef struct _IndicatorNameDef
224 {
225     ParseCommon common;
226     unsigned merge;
227     int ndx;
228     ExprDef *name;
229     Bool virtual;
230 } IndicatorNameDef;
231
232 typedef struct _IndicatorMapDef
233 {
234     ParseCommon common;
235     unsigned merge;
236     unsigned type;
237     xkb_atom_t name;
238     VarDef *body;
239 } IndicatorMapDef;
240
241 typedef struct _XkbFile
242 {
243     ParseCommon common;
244     unsigned type;
245     char *topName;
246     char *name;
247     ParseCommon *defs;
248     int id;
249     unsigned flags;
250     Bool compiled;
251 } XkbFile;
252
253 extern struct xkb_desc *
254 CompileKeymap(struct xkb_context *context, XkbFile *file, unsigned merge);
255
256 extern Bool
257 CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
258
259 extern Bool
260 CompileKeyTypes(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
261
262 typedef struct _LEDInfo *LEDInfoPtr;
263
264 extern Bool
265 CompileCompatMap(XkbFile *file, struct xkb_desc * xkb, unsigned merge,
266                  LEDInfoPtr *unboundLEDs);
267
268 extern Bool
269 CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
270
271 extern Bool
272 UpdateModifiersFromCompat(struct xkb_desc *xkb);
273
274 #endif /* XKBCOMP_H */