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