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