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