bf45dffa64486e2da819694f37bb628d79a28a76
[platform/upstream/libxkbcommon.git] / src / xkbcomp / xkbparse.y
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 %token
28         END_OF_FILE     0
29         ERROR_TOK       255
30         XKB_KEYMAP      1
31         XKB_KEYCODES    2
32         XKB_TYPES       3
33         XKB_SYMBOLS     4
34         XKB_COMPATMAP   5
35         XKB_GEOMETRY    6
36         XKB_SEMANTICS   7
37         XKB_LAYOUT      8
38         INCLUDE         10
39         OVERRIDE        11
40         AUGMENT         12
41         REPLACE         13
42         ALTERNATE       14
43         VIRTUAL_MODS    20
44         TYPE            21
45         INTERPRET       22
46         ACTION_TOK      23
47         KEY             24
48         ALIAS           25
49         GROUP           26
50         MODIFIER_MAP    27
51         INDICATOR       28
52         SHAPE           29
53         KEYS            30
54         ROW             31
55         SECTION         32
56         OVERLAY         33
57         TEXT            34
58         OUTLINE         35
59         SOLID           36
60         LOGO            37
61         VIRTUAL         38
62         EQUALS          40
63         PLUS            41
64         MINUS           42
65         DIVIDE          43
66         TIMES           44
67         OBRACE          45
68         CBRACE          46
69         OPAREN          47
70         CPAREN          48
71         OBRACKET        49
72         CBRACKET        50
73         DOT             51
74         COMMA           52
75         SEMI            53
76         EXCLAM          54
77         INVERT          55
78         STRING          60
79         INTEGER         61
80         FLOAT           62
81         IDENT           63
82         KEYNAME         64
83         PARTIAL         70
84         DEFAULT         71
85         HIDDEN          72
86         ALPHANUMERIC_KEYS       73
87         MODIFIER_KEYS           74
88         KEYPAD_KEYS             75
89         FUNCTION_KEYS           76
90         ALTERNATE_GROUP         77
91 %{
92 #define DEBUG 1
93 #ifdef DEBUG
94 #define YYDEBUG 1
95 #endif
96 #include "parseutils.h"
97 #include "xkbmisc.h"
98 #include <X11/keysym.h>
99 #include <stdlib.h>
100
101 extern int yylex(void);
102 extern FILE *yyin;
103 %}
104 %right  EQUALS
105 %left   PLUS MINUS
106 %left   TIMES DIVIDE
107 %left   EXCLAM INVERT
108 %left   OPAREN
109 %start  XkbFile
110 %union  {
111         int              ival;
112         unsigned         uval;
113         char            *str;
114         Atom            sval;
115         ParseCommon     *any;
116         ExprDef         *expr;
117         VarDef          *var;
118         VModDef         *vmod;
119         InterpDef       *interp;
120         KeyTypeDef      *keyType;
121         SymbolsDef      *syms;
122         ModMapDef       *modMask;
123         GroupCompatDef  *groupCompat;
124         IndicatorMapDef *ledMap;
125         IndicatorNameDef *ledName;
126         KeycodeDef      *keyName;
127         KeyAliasDef     *keyAlias;
128         void            *geom;
129         XkbFile         *file;
130 }
131 %type <ival>    Number Integer Float SignedNumber
132 %type <uval>    XkbCompositeType FileType MergeMode OptMergeMode
133 %type <uval>    DoodadType Flag Flags OptFlags KeyCode
134 %type <str>     KeyName MapName OptMapName KeySym
135 %type <sval>    FieldSpec Ident Element String
136 %type <any>     DeclList Decl
137 %type <expr>    OptExprList ExprList Expr Term Lhs Terminal ArrayInit
138 %type <expr>    OptKeySymList KeySymList Action ActionList Coord CoordList
139 %type <var>     VarDecl VarDeclList SymbolsBody SymbolsVarDecl
140 %type <vmod>    VModDecl VModDefList VModDef
141 %type <interp>  InterpretDecl InterpretMatch
142 %type <keyType> KeyTypeDecl
143 %type <syms>    SymbolsDecl
144 %type <modMask> ModMapDecl
145 %type <groupCompat> GroupCompatDecl
146 %type <ledMap>  IndicatorMapDecl
147 %type <ledName> IndicatorNameDecl
148 %type <keyName> KeyNameDecl
149 %type <keyAlias> KeyAliasDecl
150 %type <geom>    ShapeDecl SectionDecl SectionBody SectionBodyItem RowBody RowBodyItem
151 %type <geom>    Keys Key OverlayDecl OverlayKeyList OverlayKey OutlineList OutlineInList
152 %type <geom>    DoodadDecl
153 %type <file>    XkbFile XkbMapConfigList XkbMapConfig XkbConfig
154 %type <file>    XkbCompositeMap XkbCompMapList
155 %%
156 XkbFile         :       XkbCompMapList
157                         { $$= rtrnValue= $1; }
158                 |       XkbMapConfigList
159                         { $$= rtrnValue= $1;  }
160                 |       XkbConfig
161                         { $$= rtrnValue= $1; }
162                 ;
163
164 XkbCompMapList  :       XkbCompMapList XkbCompositeMap
165                         { $$= (XkbFile *)AppendStmt(&$1->common,&$2->common); }
166                 |       XkbCompositeMap
167                         { $$= $1; }
168                 ;
169
170 XkbCompositeMap :       OptFlags XkbCompositeType OptMapName OBRACE
171                             XkbMapConfigList
172                         CBRACE SEMI
173                         { $$= CreateXKBFile($2,$3,&$5->common,$1); }
174                 ;
175
176 XkbCompositeType:       XKB_KEYMAP      { $$= XkmKeymapFile; }
177                 |       XKB_SEMANTICS   { $$= XkmSemanticsFile; }
178                 |       XKB_LAYOUT      { $$= XkmLayoutFile; }
179                 ;
180
181 XkbMapConfigList :      XkbMapConfigList XkbMapConfig
182                         {
183                             if (!$2)
184                                 $$= $1;
185                             else
186                                 $$= (XkbFile *)AppendStmt(&$1->common,&$2->common);
187                         }
188                 |       XkbMapConfig
189                         { $$= $1; }
190                 ;
191
192 XkbMapConfig    :       OptFlags FileType OptMapName OBRACE
193                             DeclList
194                         CBRACE SEMI
195                         {
196                             if ($2 == XkmGeometryIndex)
197                                 $$= NULL;
198                             else
199                                 $$= CreateXKBFile($2,$3,$5,$1);
200                         }
201                 ;
202
203 XkbConfig       :       OptFlags FileType OptMapName DeclList
204                         {
205                             if ($2 == XkmGeometryIndex)
206                                 $$= NULL;
207                             else
208                                 $$= CreateXKBFile($2,$3,$4,$1);
209                         }
210                 ;
211
212
213 FileType        :       XKB_KEYCODES            { $$= XkmKeyNamesIndex; }
214                 |       XKB_TYPES               { $$= XkmTypesIndex; }
215                 |       XKB_COMPATMAP           { $$= XkmCompatMapIndex; }
216                 |       XKB_SYMBOLS             { $$= XkmSymbolsIndex; }
217                 |       XKB_GEOMETRY            { $$= XkmGeometryIndex; }
218                 ;
219
220 OptFlags        :       Flags                   { $$= $1; }
221                 |                               { $$= 0; }
222                 ;
223
224 Flags           :       Flags Flag              { $$= (($1)|($2)); }
225                 |       Flag                    { $$= $1; }
226                 ;
227
228 Flag            :       PARTIAL                 { $$= XkbLC_Partial; }
229                 |       DEFAULT                 { $$= XkbLC_Default; }
230                 |       HIDDEN                  { $$= XkbLC_Hidden; }
231                 |       ALPHANUMERIC_KEYS       { $$= XkbLC_AlphanumericKeys; }
232                 |       MODIFIER_KEYS           { $$= XkbLC_ModifierKeys; }
233                 |       KEYPAD_KEYS             { $$= XkbLC_KeypadKeys; }
234                 |       FUNCTION_KEYS           { $$= XkbLC_FunctionKeys; }
235                 |       ALTERNATE_GROUP         { $$= XkbLC_AlternateGroup; }
236                 ;
237
238 DeclList        :       DeclList Decl
239                         { $$= AppendStmt($1,$2); }
240                 |       { $$= NULL; }
241                 ;
242
243 Decl            :       OptMergeMode VarDecl
244                         {
245                             $2->merge= StmtSetMerge(&$2->common,$1);
246                             $$= &$2->common;
247                         }
248                 |       OptMergeMode VModDecl
249                         {
250                             $2->merge= StmtSetMerge(&$2->common,$1);
251                             $$= &$2->common;
252                         }
253                 |       OptMergeMode InterpretDecl
254                         {
255                             $2->merge= StmtSetMerge(&$2->common,$1);
256                             $$= &$2->common;
257                         }
258                 |       OptMergeMode KeyNameDecl
259                         {
260                             $2->merge= StmtSetMerge(&$2->common,$1);
261                             $$= &$2->common;
262                         }
263                 |       OptMergeMode KeyAliasDecl
264                         {
265                             $2->merge= StmtSetMerge(&$2->common,$1);
266                             $$= &$2->common;
267                         }
268                 |       OptMergeMode KeyTypeDecl
269                         {
270                             $2->merge= StmtSetMerge(&$2->common,$1);
271                             $$= &$2->common;
272                         }
273                 |       OptMergeMode SymbolsDecl
274                         {
275                             $2->merge= StmtSetMerge(&$2->common,$1);
276                             $$= &$2->common;
277                         }
278                 |       OptMergeMode ModMapDecl
279                         {
280                             $2->merge= StmtSetMerge(&$2->common,$1);
281                             $$= &$2->common;
282                         }
283                 |       OptMergeMode GroupCompatDecl
284                         {
285                             $2->merge= StmtSetMerge(&$2->common,$1);
286                             $$= &$2->common;
287                         }
288                 |       OptMergeMode IndicatorMapDecl
289                         {
290                             $2->merge= StmtSetMerge(&$2->common,$1);
291                             $$= &$2->common;
292                         }
293                 |       OptMergeMode IndicatorNameDecl
294                         {
295                             $2->merge= StmtSetMerge(&$2->common,$1);
296                             $$= &$2->common;
297                         }
298                 |       OptMergeMode ShapeDecl
299                         {
300                         }
301                 |       OptMergeMode SectionDecl
302                         {
303                         }
304                 |       OptMergeMode DoodadDecl
305                         {
306                         }
307                 |       MergeMode STRING
308                         {
309                             if ($1==MergeAltForm) {
310                                 yyerror("cannot use 'alternate' to include other maps");
311                                 $$= &IncludeCreate(scanBuf,MergeDefault)->common;
312                             }
313                             else {
314                                 $$= &IncludeCreate(scanBuf,$1)->common;
315                             }
316                         }
317                 ;
318
319 VarDecl         :       Lhs EQUALS Expr SEMI
320                         { $$= VarCreate($1,$3); }
321                 |       Ident SEMI
322                         { $$= BoolVarCreate($1,1); }
323                 |       EXCLAM Ident SEMI
324                         { $$= BoolVarCreate($2,0); }
325                 ;
326
327 KeyNameDecl     :       KeyName EQUALS KeyCode SEMI
328                         {
329                             KeycodeDef *def;
330
331                             def= KeycodeCreate($1,$3);
332                             free($1);
333                             $$= def;
334                         }
335                 ;
336
337 KeyAliasDecl    :       ALIAS KeyName EQUALS KeyName SEMI
338                         {
339                             KeyAliasDef *def;
340                             def= KeyAliasCreate($2,$4);
341                             free($2);
342                             free($4);
343                             $$= def;
344                         }
345                 ;
346
347 VModDecl        :       VIRTUAL_MODS VModDefList SEMI
348                         { $$= $2; }
349                 ;
350
351 VModDefList     :       VModDefList COMMA VModDef
352                         { $$= (VModDef *)AppendStmt(&$1->common,&$3->common); }
353                 |       VModDef
354                         { $$= $1; }
355                 ;
356
357 VModDef         :       Ident
358                         { $$= VModCreate($1,NULL); }
359                 |       Ident EQUALS Expr
360                         { $$= VModCreate($1,$3); }
361                 ;
362
363 InterpretDecl   :       INTERPRET InterpretMatch OBRACE
364                             VarDeclList
365                         CBRACE SEMI
366                         {
367                             $2->def= $4;
368                             $$= $2;
369                         }
370                 ;
371
372 InterpretMatch  :       KeySym PLUS Expr        
373                         { $$= InterpCreate($1, $3); }
374                 |       KeySym                  
375                         { $$= InterpCreate($1, NULL); }
376                 ;
377
378 VarDeclList     :       VarDeclList VarDecl
379                         { $$= (VarDef *)AppendStmt(&$1->common,&$2->common); }
380                 |       VarDecl
381                         { $$= $1; }
382                 ;
383
384 KeyTypeDecl     :       TYPE String OBRACE
385                             VarDeclList
386                         CBRACE SEMI
387                         { $$= KeyTypeCreate($2,$4); }
388                 ;
389
390 SymbolsDecl     :       KEY KeyName OBRACE
391                             SymbolsBody
392                         CBRACE SEMI
393                         { $$= SymbolsCreate($2,(ExprDef *)$4); free($2); }
394                 ;
395
396 SymbolsBody     :       SymbolsBody COMMA SymbolsVarDecl
397                         { $$= (VarDef *)AppendStmt(&$1->common,&$3->common); }
398                 |       SymbolsVarDecl
399                         { $$= $1; }
400                 |       { $$= NULL; }
401                 ;
402
403 SymbolsVarDecl  :       Lhs EQUALS Expr
404                         { $$= VarCreate($1,$3); }
405                 |       Lhs EQUALS ArrayInit
406                         { $$= VarCreate($1,$3); }
407                 |       Ident
408                         { $$= BoolVarCreate($1,1); }
409                 |       EXCLAM Ident
410                         { $$= BoolVarCreate($2,0); }
411                 |       ArrayInit
412                         { $$= VarCreate(NULL,$1); }
413                 ;
414
415 ArrayInit       :       OBRACKET OptKeySymList CBRACKET
416                         { $$= $2; }
417                 |       OBRACKET ActionList CBRACKET
418                         { $$= ExprCreateUnary(ExprActionList,TypeAction,$2); }
419                 ;
420
421 GroupCompatDecl :       GROUP Integer EQUALS Expr SEMI
422                         { $$= GroupCompatCreate($2,$4); }
423                 ;
424
425 ModMapDecl      :       MODIFIER_MAP Ident OBRACE ExprList CBRACE SEMI
426                         { $$= ModMapCreate($2,$4); }
427                 ;
428
429 IndicatorMapDecl:       INDICATOR String OBRACE VarDeclList CBRACE SEMI
430                         { $$= IndicatorMapCreate($2,$4); }
431                 ;
432
433 IndicatorNameDecl:      INDICATOR Integer EQUALS Expr SEMI
434                         { $$= IndicatorNameCreate($2,$4,False); }
435                 |       VIRTUAL INDICATOR Integer EQUALS Expr SEMI
436                         { $$= IndicatorNameCreate($3,$5,True); }
437                 ;
438
439 ShapeDecl       :       SHAPE String OBRACE OutlineList CBRACE SEMI
440                         { $$= NULL; }
441                 |       SHAPE String OBRACE CoordList CBRACE SEMI
442                         { $$= NULL; }
443                 ;
444
445 SectionDecl     :       SECTION String OBRACE SectionBody CBRACE SEMI
446                         { $$= NULL; }
447                 ;
448
449 SectionBody     :       SectionBody SectionBodyItem
450                         { $$= NULL;}
451                 |       SectionBodyItem
452                         { $$= NULL; }
453                 ;
454
455 SectionBodyItem :       ROW OBRACE RowBody CBRACE SEMI
456                         { $$= NULL; }
457                 |       VarDecl
458                         { $$= NULL; }
459                 |       DoodadDecl
460                         { $$= NULL; }
461                 |       IndicatorMapDecl
462                         { $$= NULL; }
463                 |       OverlayDecl
464                         { $$= NULL; }
465                 ;
466
467 RowBody         :       RowBody RowBodyItem
468                         { $$= NULL;}
469                 |       RowBodyItem
470                         { $$= NULL; }
471                 ;
472
473 RowBodyItem     :       KEYS OBRACE Keys CBRACE SEMI
474                         { $$= NULL; }
475                 |       VarDecl
476                         { $$= NULL; }
477                 ;
478
479 Keys            :       Keys COMMA Key
480                         { $$= NULL; }
481                 |       Key
482                         { $$= NULL; }
483                 ;
484
485 Key             :       KeyName
486                         { $$= NULL; }
487                 |       OBRACE ExprList CBRACE
488                         { $$= NULL; }
489                 ;
490
491 OverlayDecl     :       OVERLAY String OBRACE OverlayKeyList CBRACE SEMI
492                         { $$= NULL; }
493                 ;
494
495 OverlayKeyList  :       OverlayKeyList COMMA OverlayKey
496                         {
497                             $$= NULL;
498                         }
499                 |       OverlayKey
500                         { $$= NULL; }
501                 ;
502
503 OverlayKey      :       KeyName EQUALS KeyName
504                         { $$= NULL; }
505                 ;
506
507 OutlineList     :       OutlineList COMMA OutlineInList
508                         { $$= NULL;}
509                 |       OutlineInList
510                         { $$= NULL; }
511                 ;
512
513 OutlineInList   :       OBRACE CoordList CBRACE
514                         { $$= NULL; }
515                 |       Ident EQUALS OBRACE CoordList CBRACE
516                         { $$= NULL; }
517                 |       Ident EQUALS Expr
518                         { $$= NULL; }
519                 ;
520
521 CoordList       :       CoordList COMMA Coord
522                         { $$= NULL; }
523                 |       Coord
524                         { $$= NULL; }
525                 ;
526
527 Coord           :       OBRACKET SignedNumber COMMA SignedNumber CBRACKET
528                         { $$= NULL; }
529                 ;
530
531 DoodadDecl      :       DoodadType String OBRACE VarDeclList CBRACE SEMI
532                         { $$= NULL; }
533                 ;
534
535 DoodadType      :       TEXT                    { $$= 0; }
536                 |       OUTLINE                 { $$= 0; }
537                 |       SOLID                   { $$= 0; }
538                 |       LOGO                    { $$= 0; }
539                 ;
540
541 FieldSpec       :       Ident                   { $$= $1; }
542                 |       Element                 { $$= $1; }
543                 ;
544
545 Element         :       ACTION_TOK              
546                         { $$= xkb_intern_atom("action"); }
547                 |       INTERPRET
548                         { $$= xkb_intern_atom("interpret"); }
549                 |       TYPE
550                         { $$= xkb_intern_atom("type"); }
551                 |       KEY
552                         { $$= xkb_intern_atom("key"); }
553                 |       GROUP
554                         { $$= xkb_intern_atom("group"); }
555                 |       MODIFIER_MAP
556                         {$$= xkb_intern_atom("modifier_map");}
557                 |       INDICATOR
558                         { $$= xkb_intern_atom("indicator"); }
559                 |       SHAPE   
560                         { $$= xkb_intern_atom("shape"); }
561                 |       ROW     
562                         { $$= None; }
563                 |       SECTION 
564                         { $$= None; }
565                 |       TEXT
566                         { $$= None; }
567                 ;
568
569 OptMergeMode    :       MergeMode               { $$= $1; }
570                 |                               { $$= MergeDefault; }
571                 ;
572
573 MergeMode       :       INCLUDE                 { $$= MergeDefault; }
574                 |       AUGMENT                 { $$= MergeAugment; }
575                 |       OVERRIDE                { $$= MergeOverride; }
576                 |       REPLACE                 { $$= MergeReplace; }
577                 |       ALTERNATE               { $$= MergeAltForm; }
578                 ;
579
580 OptExprList     :       ExprList                        { $$= $1; }
581                 |                               { $$= NULL; }
582                 ;
583
584 ExprList        :       ExprList COMMA Expr
585                         { $$= (ExprDef *)AppendStmt(&$1->common,&$3->common); }
586                 |       Expr
587                         { $$= $1; }
588                 ;
589
590 Expr            :       Expr DIVIDE Expr
591                         { $$= ExprCreateBinary(OpDivide,$1,$3); }
592                 |       Expr PLUS Expr
593                         { $$= ExprCreateBinary(OpAdd,$1,$3); }
594                 |       Expr MINUS Expr
595                         { $$= ExprCreateBinary(OpSubtract,$1,$3); }
596                 |       Expr TIMES Expr
597                         { $$= ExprCreateBinary(OpMultiply,$1,$3); }
598                 |       Lhs EQUALS Expr
599                         { $$= ExprCreateBinary(OpAssign,$1,$3); }
600                 |       Term
601                         { $$= $1; }
602                 ;
603
604 Term            :       MINUS Term
605                         { $$= ExprCreateUnary(OpNegate,$2->type,$2); }
606                 |       PLUS Term
607                         { $$= ExprCreateUnary(OpUnaryPlus,$2->type,$2); }
608                 |       EXCLAM Term
609                         { $$= ExprCreateUnary(OpNot,TypeBoolean,$2); }
610                 |       INVERT Term
611                         { $$= ExprCreateUnary(OpInvert,$2->type,$2); }
612                 |       Lhs
613                         { $$= $1;  }
614                 |       FieldSpec OPAREN OptExprList CPAREN %prec OPAREN
615                         { $$= ActionCreate($1,$3); }
616                 |       Terminal
617                         { $$= $1;  }
618                 |       OPAREN Expr CPAREN
619                         { $$= $2;  }
620                 ;
621
622 ActionList      :       ActionList COMMA Action
623                         { $$= (ExprDef *)AppendStmt(&$1->common,&$3->common); }
624                 |       Action
625                         { $$= $1; }
626                 ;
627
628 Action          :       FieldSpec OPAREN OptExprList CPAREN
629                         { $$= ActionCreate($1,$3); }
630                 ;
631
632 Lhs             :       FieldSpec
633                         {
634                             ExprDef *expr;
635                             expr= ExprCreate(ExprIdent,TypeUnknown);
636                             expr->value.str= $1;
637                             $$= expr;
638                         }
639                 |       FieldSpec DOT FieldSpec
640                         {
641                             ExprDef *expr;
642                             expr= ExprCreate(ExprFieldRef,TypeUnknown);
643                             expr->value.field.element= $1;
644                             expr->value.field.field= $3;
645                             $$= expr;
646                         }
647                 |       FieldSpec OBRACKET Expr CBRACKET
648                         {
649                             ExprDef *expr;
650                             expr= ExprCreate(ExprArrayRef,TypeUnknown);
651                             expr->value.array.element= None;
652                             expr->value.array.field= $1;
653                             expr->value.array.entry= $3;
654                             $$= expr;
655                         }
656                 |       FieldSpec DOT FieldSpec OBRACKET Expr CBRACKET
657                         {
658                             ExprDef *expr;
659                             expr= ExprCreate(ExprArrayRef,TypeUnknown);
660                             expr->value.array.element= $1;
661                             expr->value.array.field= $3;
662                             expr->value.array.entry= $5;
663                             $$= expr;
664                         }
665                 ;
666
667 Terminal        :       String
668                         {
669                             ExprDef *expr;
670                             expr= ExprCreate(ExprValue,TypeString);
671                             expr->value.str= $1;
672                             $$= expr;
673                         }
674                 |       Integer
675                         {
676                             ExprDef *expr;
677                             expr= ExprCreate(ExprValue,TypeInt);
678                             expr->value.ival= $1;
679                             $$= expr;
680                         }
681                 |       Float
682                         {
683                             ExprDef *expr;
684                             expr= ExprCreate(ExprValue,TypeFloat);
685                             expr->value.ival= $1;
686                             $$= expr;
687                         }
688                 |       KeyName
689                         {
690                             ExprDef *expr;
691                             expr= ExprCreate(ExprValue,TypeKeyName);
692                             memset(expr->value.keyName,0,5);
693                             strncpy(expr->value.keyName,$1,4);
694                             free($1);
695                             $$= expr;
696                         }
697                 ;
698
699 OptKeySymList   :       KeySymList                      { $$= $1; }
700                 |                                       { $$= NULL; }
701                 ;
702
703 KeySymList      :       KeySymList COMMA KeySym
704                         { $$= AppendKeysymList($1,$3); }
705                 |       KeySym
706                         { $$= CreateKeysymList($1); }
707                 ;
708
709 KeySym          :       IDENT   { $$= strdup(scanBuf); }
710                 |       SECTION { $$= strdup("section"); }
711                 |       Integer         
712                         {
713                             if ($1 < 10) {      /* XK_0 .. XK_9 */
714                                 $$= malloc(2);
715                                 $$[0]= $1 + '0';
716                                 $$[1]= '\0';
717                             }
718                             else {
719                                 $$= malloc(17);
720                                 snprintf($$, 17, "0x%x", $1);
721                             }
722                         }
723                 ;
724
725 SignedNumber    :       MINUS Number    { $$= -$2; }
726                 |       Number              { $$= $1; }
727                 ;
728
729 Number          :       FLOAT           { $$= scanInt; }
730                 |       INTEGER         { $$= scanInt*XkbGeomPtsPerMM; }
731                 ;
732
733 Float           :       FLOAT           { $$= 0; }
734                 ;
735
736 Integer         :       INTEGER         { $$= scanInt; }
737                 ;
738
739 KeyCode         :       INTEGER         { $$= scanULong; }
740                 ;
741
742 KeyName         :       KEYNAME         { $$= strdup(scanBuf); }
743                 ;
744
745 Ident           :       IDENT   { $$= xkb_intern_atom(scanBuf); }
746                 |       DEFAULT { $$= xkb_intern_atom("default"); }
747                 ;
748
749 String          :       STRING  { $$= xkb_intern_atom(scanBuf); }
750                 ;
751
752 OptMapName      :       MapName { $$= $1; }
753                 |               { $$= NULL; }
754                 ;
755
756 MapName         :       STRING  { $$= strdup(scanBuf); }
757                 ;