xkbparse.y revision f46a6179
1/* $Xorg: xkbparse.y,v 1.3 2000/08/17 19:54:34 cpqbld Exp $ */
2/************************************************************
3 Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
4
5 Permission to use, copy, modify, and distribute this
6 software and its documentation for any purpose and without
7 fee is hereby granted, provided that the above copyright
8 notice appear in all copies and that both that copyright
9 notice and this permission notice appear in supporting
10 documentation, and that the name of Silicon Graphics not be
11 used in advertising or publicity pertaining to distribution
12 of the software without specific prior written permission.
13 Silicon Graphics makes no representation about the suitability
14 of this software for any purpose. It is provided "as is"
15 without any express or implied warranty.
16
17 SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
18 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
20 GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
21 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
22 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
23 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
24 THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
26 ********************************************************/
27/* $XFree86: xc/programs/xkbcomp/xkbparse.y,v 3.11tsi Exp $ */
28
29%token
30	END_OF_FILE	0
31	ERROR_TOK	255
32	XKB_KEYMAP	1
33	XKB_KEYCODES	2
34	XKB_TYPES	3
35	XKB_SYMBOLS	4
36	XKB_COMPATMAP	5
37	XKB_GEOMETRY	6
38	XKB_SEMANTICS	7
39	XKB_LAYOUT	8
40	INCLUDE		10
41	OVERRIDE	11
42	AUGMENT		12
43	REPLACE		13
44	ALTERNATE	14
45	VIRTUAL_MODS	20
46	TYPE		21
47	INTERPRET	22
48	ACTION_TOK	23
49	KEY		24
50	ALIAS		25
51	GROUP		26
52	MODIFIER_MAP	27
53	INDICATOR	28
54	SHAPE		29
55	KEYS		30
56	ROW		31
57	SECTION		32
58	OVERLAY		33
59	TEXT		34
60	OUTLINE		35
61	SOLID		36
62	LOGO		37
63	VIRTUAL		38
64	EQUALS		40
65	PLUS		41
66	MINUS		42
67	DIVIDE		43
68	TIMES		44
69	OBRACE		45
70	CBRACE		46
71	OPAREN		47
72	CPAREN		48
73	OBRACKET	49
74	CBRACKET	50
75	DOT		51
76	COMMA		52
77	SEMI		53
78	EXCLAM		54
79	INVERT		55
80	STRING		60
81	INTEGER		61
82	FLOAT		62
83	IDENT		63
84	KEYNAME		64
85	PARTIAL		70
86	DEFAULT		71
87	HIDDEN		72
88	ALPHANUMERIC_KEYS	73
89	MODIFIER_KEYS		74
90	KEYPAD_KEYS		75
91	FUNCTION_KEYS		76
92	ALTERNATE_GROUP		77
93%{
94#ifdef DEBUG
95#define	YYDEBUG 1
96#endif
97#define	DEBUG_VAR parseDebug
98#include "parseutils.h"
99#include <X11/keysym.h>
100#include <X11/extensions/XKBgeom.h>
101#include <stdlib.h>
102
103
104%}
105%right	EQUALS
106%left	PLUS MINUS
107%left	TIMES DIVIDE
108%left	EXCLAM INVERT
109%left	OPAREN
110%start	XkbFile
111%union	{
112	int		 ival;
113	unsigned	 uval;
114	char		*str;
115	Atom	 	sval;
116	ParseCommon	*any;
117	ExprDef		*expr;
118	VarDef		*var;
119	VModDef		*vmod;
120	InterpDef	*interp;
121	KeyTypeDef	*keyType;
122	SymbolsDef	*syms;
123	ModMapDef	*modMask;
124	GroupCompatDef	*groupCompat;
125	IndicatorMapDef	*ledMap;
126	IndicatorNameDef *ledName;
127	KeycodeDef	*keyName;
128	KeyAliasDef	*keyAlias;
129	ShapeDef	*shape;
130	SectionDef	*section;
131	RowDef		*row;
132	KeyDef		*key;
133	OverlayDef	*overlay;
134	OverlayKeyDef	*olKey;
135	OutlineDef	*outline;
136	DoodadDef	*doodad;
137	XkbFile		*file;
138}
139%type <ival>	Number Integer Float SignedNumber
140%type <uval>	XkbCompositeType FileType MergeMode OptMergeMode KeySym
141%type <uval>	DoodadType Flag Flags OptFlags
142%type <str>	KeyName MapName OptMapName
143%type <sval>	FieldSpec Ident Element String
144%type <any>	DeclList Decl
145%type <expr>	OptExprList ExprList Expr Term Lhs Terminal ArrayInit
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 <shape>	ShapeDecl
159%type <section>	SectionDecl
160%type <row>	SectionBody SectionBodyItem
161%type <key>	RowBody RowBodyItem Keys Key
162%type <overlay>	OverlayDecl
163%type <olKey>	OverlayKeyList OverlayKey
164%type <outline>	OutlineList OutlineInList
165%type <doodad>	DoodadDecl
166%type <file>	XkbFile XkbMapConfigList XkbMapConfig XkbConfig
167%type <file>	XkbCompositeMap XkbCompMapList
168%%
169XkbFile		:	XkbCompMapList
170			{ $$= rtrnValue= $1; }
171		|	XkbMapConfigList
172			{ $$= rtrnValue= $1;  }
173		|	XkbConfig
174			{ $$= rtrnValue= $1; }
175		;
176
177XkbCompMapList	:	XkbCompMapList XkbCompositeMap
178			{ $$= (XkbFile *)AppendStmt(&$1->common,&$2->common); }
179		|	XkbCompositeMap
180			{ $$= $1; }
181		;
182
183XkbCompositeMap	:	OptFlags XkbCompositeType OptMapName OBRACE
184			    XkbMapConfigList
185			CBRACE SEMI
186			{ $$= CreateXKBFile($2,$3,&$5->common,$1); }
187		;
188
189XkbCompositeType:	XKB_KEYMAP	{ $$= XkmKeymapFile; }
190		|	XKB_SEMANTICS	{ $$= XkmSemanticsFile; }
191		|	XKB_LAYOUT	{ $$= XkmLayoutFile; }
192		;
193
194XkbMapConfigList :	XkbMapConfigList XkbMapConfig
195			{ $$= (XkbFile *)AppendStmt(&$1->common,&$2->common); }
196		|	XkbMapConfig
197			{ $$= $1; }
198		;
199
200XkbMapConfig	:	OptFlags FileType OptMapName OBRACE
201			    DeclList
202			CBRACE SEMI
203			{ $$= CreateXKBFile($2,$3,$5,$1); }
204		;
205
206XkbConfig	:	OptFlags FileType OptMapName DeclList
207			{ $$= CreateXKBFile($2,$3,$4,$1); }
208		;
209
210
211FileType	:	XKB_KEYCODES		{ $$= XkmKeyNamesIndex; }
212		|	XKB_TYPES		{ $$= XkmTypesIndex; }
213		|	XKB_COMPATMAP		{ $$= XkmCompatMapIndex; }
214		|	XKB_SYMBOLS		{ $$= XkmSymbolsIndex; }
215		|	XKB_GEOMETRY		{ $$= XkmGeometryIndex; }
216		;
217
218OptFlags	:	Flags			{ $$= $1; }
219		|				{ $$= 0; }
220		;
221
222Flags		:	Flags Flag		{ $$= (($1)|($2)); }
223		|	Flag			{ $$= $1; }
224		;
225
226Flag		:	PARTIAL			{ $$= XkbLC_Partial; }
227		|	DEFAULT			{ $$= XkbLC_Default; }
228		|	HIDDEN			{ $$= XkbLC_Hidden; }
229		|	ALPHANUMERIC_KEYS	{ $$= XkbLC_AlphanumericKeys; }
230		|	MODIFIER_KEYS		{ $$= XkbLC_ModifierKeys; }
231		|	KEYPAD_KEYS		{ $$= XkbLC_KeypadKeys; }
232		|	FUNCTION_KEYS		{ $$= XkbLC_FunctionKeys; }
233		|	ALTERNATE_GROUP		{ $$= XkbLC_AlternateGroup; }
234		;
235
236DeclList	:	DeclList Decl
237			{ $$= AppendStmt($1,$2); }
238		|	{ $$= NULL; }
239		;
240
241Decl		:	OptMergeMode VarDecl
242			{
243			    $2->merge= StmtSetMerge(&$2->common,$1);
244			    $$= &$2->common;
245			}
246		|	OptMergeMode VModDecl
247			{
248			    $2->merge= StmtSetMerge(&$2->common,$1);
249			    $$= &$2->common;
250			}
251		|	OptMergeMode InterpretDecl
252			{
253			    $2->merge= StmtSetMerge(&$2->common,$1);
254			    $$= &$2->common;
255			}
256		|	OptMergeMode KeyNameDecl
257			{
258			    $2->merge= StmtSetMerge(&$2->common,$1);
259			    $$= &$2->common;
260			}
261		|	OptMergeMode KeyAliasDecl
262			{
263			    $2->merge= StmtSetMerge(&$2->common,$1);
264			    $$= &$2->common;
265			}
266		|	OptMergeMode KeyTypeDecl
267			{
268			    $2->merge= StmtSetMerge(&$2->common,$1);
269			    $$= &$2->common;
270			}
271		|	OptMergeMode SymbolsDecl
272			{
273			    $2->merge= StmtSetMerge(&$2->common,$1);
274			    $$= &$2->common;
275			}
276		|	OptMergeMode ModMapDecl
277			{
278			    $2->merge= StmtSetMerge(&$2->common,$1);
279			    $$= &$2->common;
280			}
281		|	OptMergeMode GroupCompatDecl
282			{
283			    $2->merge= StmtSetMerge(&$2->common,$1);
284			    $$= &$2->common;
285			}
286		|	OptMergeMode IndicatorMapDecl
287			{
288			    $2->merge= StmtSetMerge(&$2->common,$1);
289			    $$= &$2->common;
290			}
291		|	OptMergeMode IndicatorNameDecl
292			{
293			    $2->merge= StmtSetMerge(&$2->common,$1);
294			    $$= &$2->common;
295			}
296		|	OptMergeMode ShapeDecl
297			{
298			    $2->merge= StmtSetMerge(&$2->common,$1);
299			    $$= &$2->common;
300			}
301		|	OptMergeMode SectionDecl
302			{
303			    $2->merge= StmtSetMerge(&$2->common,$1);
304			    $$= &$2->common;
305			}
306		|	OptMergeMode DoodadDecl
307			{
308			    $2->merge= StmtSetMerge(&$2->common,$1);
309			    $$= &$2->common;
310			}
311		|	MergeMode STRING
312			{
313			    if ($1==MergeAltForm) {
314				yyerror("cannot use 'alternate' to include other maps");
315				$$= &IncludeCreate(scanStr,MergeDefault)->common;
316			    }
317			    else {
318				$$= &IncludeCreate(scanStr,$1)->common;
319			    }
320                        }
321		;
322
323VarDecl		:	Lhs EQUALS Expr SEMI
324			{ $$= VarCreate($1,$3); }
325		|	Ident SEMI
326			{ $$= BoolVarCreate($1,1); }
327		|	EXCLAM Ident SEMI
328			{ $$= BoolVarCreate($2,0); }
329		;
330
331KeyNameDecl	:	KeyName EQUALS Expr SEMI
332                        {
333			    KeycodeDef *def;
334
335			    def= KeycodeCreate($1,$3);
336			    if ($1)
337				free($1);
338			    $$= def;
339			}
340		;
341
342KeyAliasDecl	:	ALIAS KeyName EQUALS KeyName SEMI
343			{
344			    KeyAliasDef	*def;
345			    def= KeyAliasCreate($2,$4);
346			    if ($2)	free($2);
347			    if ($4)	free($4);
348			    $$= def;
349			}
350		;
351
352VModDecl	:	VIRTUAL_MODS VModDefList SEMI
353			{ $$= $2; }
354		;
355
356VModDefList	:	VModDefList COMMA VModDef
357			{ $$= (VModDef *)AppendStmt(&$1->common,&$3->common); }
358		|	VModDef
359			{ $$= $1; }
360		;
361
362VModDef		:	Ident
363			{ $$= VModCreate($1,NULL); }
364		|	Ident EQUALS Expr
365			{ $$= VModCreate($1,$3); }
366		;
367
368InterpretDecl	:	INTERPRET InterpretMatch OBRACE
369			    VarDeclList
370			CBRACE SEMI
371			{
372			    $2->def= $4;
373			    $$= $2;
374			}
375		;
376
377InterpretMatch	:	KeySym PLUS Expr
378			{ $$= InterpCreate((KeySym)$1,$3); }
379		|	KeySym
380			{ $$= InterpCreate((KeySym)$1,NULL); }
381		;
382
383VarDeclList	:	VarDeclList VarDecl
384			{ $$= (VarDef *)AppendStmt(&$1->common,&$2->common); }
385		|	VarDecl
386			{ $$= $1; }
387		;
388
389KeyTypeDecl	:	TYPE String OBRACE
390			    VarDeclList
391			CBRACE SEMI
392			{ $$= KeyTypeCreate($2,$4); }
393		;
394
395SymbolsDecl	:	KEY KeyName OBRACE
396			    SymbolsBody
397			CBRACE SEMI
398			{ $$= SymbolsCreate($2,(ExprDef *)$4); }
399		;
400
401SymbolsBody	:	SymbolsBody COMMA SymbolsVarDecl
402			{ $$= (VarDef *)AppendStmt(&$1->common,&$3->common); }
403		|	SymbolsVarDecl
404			{ $$= $1; }
405		|	{ $$= NULL; }
406		;
407
408SymbolsVarDecl	:	Lhs EQUALS Expr
409			{ $$= VarCreate($1,$3); }
410		|	Lhs EQUALS ArrayInit
411			{ $$= VarCreate($1,$3); }
412		|	Ident
413			{ $$= BoolVarCreate($1,1); }
414		|	EXCLAM Ident
415			{ $$= BoolVarCreate($2,0); }
416		|	ArrayInit
417			{ $$= VarCreate(NULL,$1); }
418		;
419
420ArrayInit	:	OBRACKET OptKeySymList CBRACKET
421			{ $$= $2; }
422		|	OBRACKET ActionList CBRACKET
423			{ $$= ExprCreateUnary(ExprActionList,TypeAction,$2); }
424		;
425
426GroupCompatDecl	:	GROUP Integer EQUALS Expr SEMI
427			{ $$= GroupCompatCreate($2,$4); }
428		;
429
430ModMapDecl	:	MODIFIER_MAP Ident OBRACE ExprList CBRACE SEMI
431			{ $$= ModMapCreate($2,$4); }
432		;
433
434IndicatorMapDecl:	INDICATOR String OBRACE VarDeclList CBRACE SEMI
435			{ $$= IndicatorMapCreate($2,$4); }
436		;
437
438IndicatorNameDecl:	INDICATOR Integer EQUALS Expr SEMI
439			{ $$= IndicatorNameCreate($2,$4,False); }
440		|	VIRTUAL INDICATOR Integer EQUALS Expr SEMI
441			{ $$= IndicatorNameCreate($3,$5,True); }
442		;
443
444ShapeDecl	:	SHAPE String OBRACE OutlineList CBRACE SEMI
445			{ $$= ShapeDeclCreate($2,(OutlineDef *)&$4->common); }
446		|	SHAPE String OBRACE CoordList CBRACE SEMI
447			{
448			    OutlineDef *outlines;
449			    outlines= OutlineCreate(None,$4);
450			    $$= ShapeDeclCreate($2,outlines);
451			}
452		;
453
454SectionDecl	:	SECTION String OBRACE SectionBody CBRACE SEMI
455			{ $$= SectionDeclCreate($2,$4); }
456		;
457
458SectionBody	:	SectionBody SectionBodyItem
459			{ $$=(RowDef *)AppendStmt(&$1->common,&$2->common);}
460		|	SectionBodyItem
461			{ $$= $1; }
462		;
463
464SectionBodyItem	:	ROW OBRACE RowBody CBRACE SEMI
465			{ $$= RowDeclCreate($3); }
466		|	VarDecl
467			{ $$= (RowDef *)$1; }
468		|	DoodadDecl
469			{ $$= (RowDef *)$1; }
470		|	IndicatorMapDecl
471			{ $$= (RowDef *)$1; }
472		|	OverlayDecl
473			{ $$= (RowDef *)$1; }
474		;
475
476RowBody		:	RowBody RowBodyItem
477			{ $$=(KeyDef *)AppendStmt(&$1->common,&$2->common);}
478		|	RowBodyItem
479			{ $$= $1; }
480		;
481
482RowBodyItem	:	KEYS OBRACE Keys CBRACE SEMI
483			{ $$= $3; }
484		|	VarDecl
485			{ $$= (KeyDef *)$1; }
486		;
487
488Keys		:	Keys COMMA Key
489			{ $$=(KeyDef *)AppendStmt(&$1->common,&$3->common);}
490		|	Key
491			{ $$= $1; }
492		;
493
494Key		:	KeyName
495			{ $$= KeyDeclCreate($1,NULL); }
496		|	OBRACE ExprList CBRACE
497			{ $$= KeyDeclCreate(NULL,$2); }
498		;
499
500OverlayDecl	:	OVERLAY String OBRACE OverlayKeyList CBRACE SEMI
501			{ $$= OverlayDeclCreate($2,$4); }
502		;
503
504OverlayKeyList	:	OverlayKeyList COMMA OverlayKey
505			{
506			    $$= (OverlayKeyDef *)
507				AppendStmt(&$1->common,&$3->common);
508			}
509		|	OverlayKey
510			{ $$= $1; }
511		;
512
513OverlayKey	:	KeyName EQUALS KeyName
514			{ $$= OverlayKeyCreate($1,$3); }
515		;
516
517OutlineList	:	OutlineList COMMA OutlineInList
518			{ $$=(OutlineDef *)AppendStmt(&$1->common,&$3->common);}
519		|	OutlineInList
520			{ $$= $1; }
521		;
522
523OutlineInList	:	OBRACE CoordList CBRACE
524			{ $$= OutlineCreate(None,$2); }
525		|	Ident EQUALS OBRACE CoordList CBRACE
526			{ $$= OutlineCreate($1,$4); }
527		|	Ident EQUALS Expr
528			{ $$= OutlineCreate($1,$3); }
529		;
530
531CoordList	:	CoordList COMMA Coord
532			{ $$= (ExprDef *)AppendStmt(&$1->common,&$3->common); }
533		|	Coord
534			{ $$= $1; }
535		;
536
537Coord		:	OBRACKET SignedNumber COMMA SignedNumber CBRACKET
538			{
539			    ExprDef *expr;
540			    expr= ExprCreate(ExprCoord,TypeUnknown);
541			    expr->value.coord.x= $2;
542			    expr->value.coord.y= $4;
543			    $$= expr;
544			}
545		;
546
547DoodadDecl	:	DoodadType String OBRACE VarDeclList CBRACE SEMI
548			{ $$= DoodadCreate($1,$2,$4); }
549		;
550
551DoodadType	:	TEXT			{ $$= XkbTextDoodad; }
552		|	OUTLINE			{ $$= XkbOutlineDoodad; }
553		|	SOLID			{ $$= XkbSolidDoodad; }
554		|	LOGO			{ $$= XkbLogoDoodad; }
555		;
556
557FieldSpec	:	Ident			{ $$= $1; }
558		|	Element			{ $$= $1; }
559		;
560
561Element		:	ACTION_TOK
562			{ $$= XkbInternAtom(NULL,"action",False); }
563		|	INTERPRET
564			{ $$= XkbInternAtom(NULL,"interpret",False); }
565		|	TYPE
566			{ $$= XkbInternAtom(NULL,"type",False); }
567		|	KEY
568			{ $$= XkbInternAtom(NULL,"key",False); }
569		|	GROUP
570			{ $$= XkbInternAtom(NULL,"group",False); }
571		|	MODIFIER_MAP
572			{$$=XkbInternAtom(NULL,"modifier_map",False);}
573		|	INDICATOR
574			{ $$= XkbInternAtom(NULL,"indicator",False); }
575		|	SHAPE
576			{ $$= XkbInternAtom(NULL,"shape",False); }
577		|	ROW
578			{ $$= XkbInternAtom(NULL,"row",False); }
579		|	SECTION
580			{ $$= XkbInternAtom(NULL,"section",False); }
581		|	TEXT
582			{ $$= XkbInternAtom(NULL,"text",False); }
583		;
584
585OptMergeMode	:	MergeMode		{ $$= $1; }
586		|				{ $$= MergeDefault; }
587		;
588
589MergeMode	:	INCLUDE			{ $$= MergeDefault; }
590		|	AUGMENT			{ $$= MergeAugment; }
591		|	OVERRIDE		{ $$= MergeOverride; }
592		|	REPLACE			{ $$= MergeReplace; }
593		|	ALTERNATE		{ $$= MergeAltForm; }
594		;
595
596OptExprList	:	ExprList			{ $$= $1; }
597		|				{ $$= NULL; }
598		;
599
600ExprList	:	ExprList COMMA Expr
601			{ $$= (ExprDef *)AppendStmt(&$1->common,&$3->common); }
602		|	Expr
603			{ $$= $1; }
604		;
605
606Expr		:	Expr DIVIDE Expr
607			{ $$= ExprCreateBinary(OpDivide,$1,$3); }
608		|	Expr PLUS Expr
609			{ $$= ExprCreateBinary(OpAdd,$1,$3); }
610		|	Expr MINUS Expr
611			{ $$= ExprCreateBinary(OpSubtract,$1,$3); }
612		|	Expr TIMES Expr
613			{ $$= ExprCreateBinary(OpMultiply,$1,$3); }
614		|	Lhs EQUALS Expr
615			{ $$= ExprCreateBinary(OpAssign,$1,$3); }
616		|	Term
617			{ $$= $1; }
618		;
619
620Term		:	MINUS Term
621			{ $$= ExprCreateUnary(OpNegate,$2->type,$2); }
622		|	PLUS Term
623			{ $$= ExprCreateUnary(OpUnaryPlus,$2->type,$2); }
624		|	EXCLAM Term
625			{ $$= ExprCreateUnary(OpNot,TypeBoolean,$2); }
626		|	INVERT Term
627			{ $$= ExprCreateUnary(OpInvert,$2->type,$2); }
628		|	Lhs
629			{ $$= $1;  }
630		|	FieldSpec OPAREN OptExprList CPAREN %prec OPAREN
631			{ $$= ActionCreate($1,$3); }
632		|	Terminal
633			{ $$= $1;  }
634		|	OPAREN Expr CPAREN
635			{ $$= $2;  }
636		;
637
638ActionList	:	ActionList COMMA Action
639			{ $$= (ExprDef *)AppendStmt(&$1->common,&$3->common); }
640		|	Action
641			{ $$= $1; }
642		;
643
644Action		:	FieldSpec OPAREN OptExprList CPAREN
645			{ $$= ActionCreate($1,$3); }
646		;
647
648Lhs		:	FieldSpec
649			{
650			    ExprDef *expr;
651                            expr= ExprCreate(ExprIdent,TypeUnknown);
652                            expr->value.str= $1;
653                            $$= expr;
654			}
655		|	FieldSpec DOT FieldSpec
656                        {
657                            ExprDef *expr;
658                            expr= ExprCreate(ExprFieldRef,TypeUnknown);
659                            expr->value.field.element= $1;
660                            expr->value.field.field= $3;
661                            $$= expr;
662			}
663		|	FieldSpec OBRACKET Expr CBRACKET
664			{
665			    ExprDef *expr;
666			    expr= ExprCreate(ExprArrayRef,TypeUnknown);
667			    expr->value.array.element= None;
668			    expr->value.array.field= $1;
669			    expr->value.array.entry= $3;
670			    $$= expr;
671			}
672		|	FieldSpec DOT FieldSpec OBRACKET Expr CBRACKET
673			{
674			    ExprDef *expr;
675			    expr= ExprCreate(ExprArrayRef,TypeUnknown);
676			    expr->value.array.element= $1;
677			    expr->value.array.field= $3;
678			    expr->value.array.entry= $5;
679			    $$= expr;
680			}
681		;
682
683Terminal	:	String
684			{
685			    ExprDef *expr;
686                            expr= ExprCreate(ExprValue,TypeString);
687                            expr->value.str= $1;
688                            $$= expr;
689			}
690		|	Integer
691			{
692			    ExprDef *expr;
693                            expr= ExprCreate(ExprValue,TypeInt);
694                            expr->value.ival= $1;
695                            $$= expr;
696			}
697		|	Float
698			{
699			    ExprDef *expr;
700			    expr= ExprCreate(ExprValue,TypeFloat);
701			    expr->value.ival= $1;
702			    $$= expr;
703			}
704		|	KeyName
705			{
706			    ExprDef *expr;
707			    expr= ExprCreate(ExprValue,TypeKeyName);
708			    memset(expr->value.keyName,0,5);
709			    strncpy(expr->value.keyName,$1,4);
710			    free($1);
711			    $$= expr;
712			}
713		;
714
715OptKeySymList	:	KeySymList			{ $$= $1; }
716		|					{ $$= NULL; }
717		;
718
719KeySymList	:	KeySymList COMMA KeySym
720			{ $$= AppendKeysymList($1,(KeySym)$3); }
721		|	KeySym
722			{ $$= CreateKeysymList((KeySym)$1); }
723		;
724
725KeySym		:	IDENT
726			{
727			    KeySym sym;
728			    if (LookupKeysym(scanStr,&sym))
729				$$= sym;
730			    else {
731				char buf[120];
732				sprintf(buf,"expected keysym, got %s",
733							uStringText(scanStr));
734				yyerror(buf);
735				yynerrs++;
736				$$= NoSymbol;
737			    }
738			}
739		|	SECTION
740			{
741			    $$= XK_section;
742			}
743		|	Integer
744			{
745			    if ($1<10)	$$= $1+'0';	/* XK_0 .. XK_9 */
746			    else	$$= $1;
747			}
748		;
749
750SignedNumber	:	MINUS Number    { $$= -$2; }
751		|	Number              { $$= $1; }
752		;
753
754Number		:	FLOAT		{ $$= scanInt; }
755		|	INTEGER		{ $$= scanInt*XkbGeomPtsPerMM; }
756		;
757
758Float		:	FLOAT		{ $$= scanInt; }
759		;
760
761Integer		:	INTEGER		{ $$= scanInt; }
762		;
763
764KeyName		:	KEYNAME		{ $$= scanStr; scanStr= NULL; }
765		;
766
767Ident		:	IDENT	{ $$= XkbInternAtom(NULL,scanStr,False); }
768		|	DEFAULT { $$= XkbInternAtom(NULL,"default",False); }
769		;
770
771String		:	STRING	{ $$= XkbInternAtom(NULL,scanStr,False); }
772		;
773
774OptMapName	:	MapName	{ $$= $1; }
775		|		{ $$= NULL; }
776		;
777
778MapName		:	STRING 	{ $$= scanStr; scanStr= NULL; }
779		;
780%%
781void
782yyerror(const char *s)
783{
784    if (warningLevel>0) {
785	(void)fprintf(stderr,"%s: line %d of %s\n",s,lineNum,
786					(scanFile?scanFile:"(unknown)"));
787	if ((scanStr)&&(warningLevel>3))
788	    (void)fprintf(stderr,"last scanned symbol is: %s\n",scanStr);
789    }
790    return;
791}
792
793
794int
795yywrap(void)
796{
797   return 1;
798}
799
800