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