Use CARD32 instead of Atom, move geom headers in
[platform/upstream/libxkbcommon.git] / src / xkbcomp / xkbparse.y
index 63f87bb..ae37f7a 100644 (file)
@@ -6,19 +6,19 @@
  fee is hereby granted, provided that the above copyright
  notice appear in all copies and that both that copyright
  notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be 
- used in advertising or publicity pertaining to distribution 
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
  of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability 
+ Silicon Graphics makes no representation about the suitability
  of this software for any purpose. It is provided "as is"
  without any express or implied warranty.
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+ GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
@@ -94,8 +94,9 @@
 #endif
 #define        DEBUG_VAR parseDebug
 #include "parseutils.h"
+#include "xkbmisc.h"
+#include <X11/Xlib.h>
 #include <X11/keysym.h>
-#include <X11/extensions/XKBgeom.h>
 #include <stdlib.h>
 
 unsigned int parseDebug;
@@ -136,14 +137,14 @@ unsigned int parseDebug;
        XkbFile         *file;
 }
 %type <ival>   Number Integer Float SignedNumber
-%type <uval>   XkbCompositeType FileType MergeMode OptMergeMode KeySym
+%type <uval>   XkbCompositeType FileType MergeMode OptMergeMode
 %type <uval>   DoodadType Flag Flags OptFlags
-%type <str>    KeyName MapName OptMapName
-%type <sval>   FieldSpec Ident Element String 
-%type <any>    DeclList Decl 
+%type <str>    KeyName MapName OptMapName KeySym
+%type <sval>   FieldSpec Ident Element String
+%type <any>    DeclList Decl
 %type <expr>   OptExprList ExprList Expr Term Lhs Terminal ArrayInit
 %type <expr>   OptKeySymList KeySymList Action ActionList Coord CoordList
-%type <var>    VarDecl VarDeclList SymbolsBody SymbolsVarDecl 
+%type <var>    VarDecl VarDeclList SymbolsBody SymbolsVarDecl
 %type <vmod>   VModDecl VModDefList VModDef
 %type <interp> InterpretDecl InterpretMatch
 %type <keyType>        KeyTypeDecl
@@ -157,7 +158,7 @@ unsigned int parseDebug;
 %type <shape>  ShapeDecl
 %type <section>        SectionDecl
 %type <row>    SectionBody SectionBodyItem
-%type <key>    RowBody RowBodyItem Keys Key 
+%type <key>    RowBody RowBodyItem Keys Key
 %type <overlay>        OverlayDecl
 %type <olKey>  OverlayKeyList OverlayKey
 %type <outline>        OutlineList OutlineInList
@@ -167,7 +168,7 @@ unsigned int parseDebug;
 %%
 XkbFile                :       XkbCompMapList
                        { $$= rtrnValue= $1; }
-               |       XkbMapConfigList 
+               |       XkbMapConfigList
                        { $$= rtrnValue= $1;  }
                |       XkbConfig
                        { $$= rtrnValue= $1; }
@@ -311,10 +312,10 @@ Decl              :       OptMergeMode VarDecl
                        {
                            if ($1==MergeAltForm) {
                                yyerror("cannot use 'alternate' to include other maps");
-                               $$= &IncludeCreate(scanStr,MergeDefault)->common;
+                               $$= &IncludeCreate(scanBuf,MergeDefault)->common;
                            }
                            else {
-                               $$= &IncludeCreate(scanStr,$1)->common;
+                               $$= &IncludeCreate(scanBuf,$1)->common;
                            }
                         }
                ;
@@ -339,9 +340,9 @@ KeyNameDecl :       KeyName EQUALS Expr SEMI
                ;
 
 KeyAliasDecl   :       ALIAS KeyName EQUALS KeyName SEMI
-                       { 
+                       {
                            KeyAliasDef *def;
-                           def= KeyAliasCreate($2,$4); 
+                           def= KeyAliasCreate($2,$4);
                            if ($2)     free($2);       
                            if ($4)     free($4);       
                            $$= def;
@@ -374,9 +375,9 @@ InterpretDecl       :       INTERPRET InterpretMatch OBRACE
                ;
 
 InterpretMatch :       KeySym PLUS Expr        
-                       { $$= InterpCreate((KeySym)$1,$3); }
+                       { $$= InterpCreate($1, $3); }
                |       KeySym                  
-                       { $$= InterpCreate((KeySym)$1,NULL); }
+                       { $$= InterpCreate($1, NULL); }
                ;
 
 VarDeclList    :       VarDeclList VarDecl
@@ -443,7 +444,7 @@ IndicatorNameDecl:  INDICATOR Integer EQUALS Expr SEMI
 ShapeDecl      :       SHAPE String OBRACE OutlineList CBRACE SEMI
                        { $$= ShapeDeclCreate($2,(OutlineDef *)&$4->common); }
                |       SHAPE String OBRACE CoordList CBRACE SEMI
-                       { 
+                       {
                            OutlineDef *outlines;
                            outlines= OutlineCreate(None,$4);
                            $$= ShapeDeclCreate($2,outlines);
@@ -501,7 +502,7 @@ OverlayDecl :       OVERLAY String OBRACE OverlayKeyList CBRACE SEMI
                ;
 
 OverlayKeyList :       OverlayKeyList COMMA OverlayKey
-                       { 
+                       {
                            $$= (OverlayKeyDef *)
                                AppendStmt(&$1->common,&$3->common);
                        }
@@ -558,27 +559,27 @@ FieldSpec :       Ident                   { $$= $1; }
                ;
 
 Element                :       ACTION_TOK              
-                       { $$= XkbInternAtom(NULL,"action",False); }
+                       { $$= XkbcInternAtom("action",False); }
                |       INTERPRET
-                       { $$= XkbInternAtom(NULL,"interpret",False); }
+                       { $$= XkbcInternAtom("interpret",False); }
                |       TYPE
-                       { $$= XkbInternAtom(NULL,"type",False); }
+                       { $$= XkbcInternAtom("type",False); }
                |       KEY
-                       { $$= XkbInternAtom(NULL,"key",False); }
+                       { $$= XkbcInternAtom("key",False); }
                |       GROUP
-                       { $$= XkbInternAtom(NULL,"group",False); }
+                       { $$= XkbcInternAtom("group",False); }
                |       MODIFIER_MAP
-                       {$$=XkbInternAtom(NULL,"modifier_map",False);}
+                       {$$=XkbcInternAtom("modifier_map",False);}
                |       INDICATOR
-                       { $$= XkbInternAtom(NULL,"indicator",False); }
+                       { $$= XkbcInternAtom("indicator",False); }
                |       SHAPE   
-                       { $$= XkbInternAtom(NULL,"shape",False); }
+                       { $$= XkbcInternAtom("shape",False); }
                |       ROW     
-                       { $$= XkbInternAtom(NULL,"row",False); }
+                       { $$= XkbcInternAtom("row",False); }
                |       SECTION 
-                       { $$= XkbInternAtom(NULL,"section",False); }
+                       { $$= XkbcInternAtom("section",False); }
                |       TEXT
-                       { $$= XkbInternAtom(NULL,"text",False); }
+                       { $$= XkbcInternAtom("text",False); }
                ;
 
 OptMergeMode   :       MergeMode               { $$= $1; }
@@ -716,34 +717,24 @@ OptKeySymList     :       KeySymList                      { $$= $1; }
                ;
 
 KeySymList     :       KeySymList COMMA KeySym
-                       { $$= AppendKeysymList($1,(KeySym)$3); }
+                       { $$= AppendKeysymList($1,$3); }
                |       KeySym
-                       { $$= CreateKeysymList((KeySym)$1); }
+                       { $$= CreateKeysymList($1); }
                ;
 
-KeySym         :       IDENT
-                       { 
-                           KeySym sym;
-                           if (LookupKeysym(scanStr,&sym))
-                               $$= sym;
-                           else {
-                               char buf[120];
-                               snprintf(buf, sizeof(buf),
-                                        "expected keysym, got %s",
-                                        uStringText(scanStr));
-                               yyerror(buf);
-                               yynerrs++;
-                               $$= NoSymbol;
-                           }
-                       }
-               |       SECTION
-                       {
-                           $$= XK_section;
-                       }
+KeySym         :       IDENT   { $$= strdup(scanBuf); }
+               |       SECTION { $$= strdup("section"); }
                |       Integer         
                        {
-                           if ($1<10)  $$= $1+'0';     /* XK_0 .. XK_9 */
-                           else        $$= $1;
+                           if ($1 < 10) {      /* XK_0 .. XK_9 */
+                               $$= malloc(2);
+                               $$[0]= $1 + '0';
+                               $$[1]= '\0';
+                           }
+                           else {
+                               $$= malloc(17);
+                               snprintf($$, 17, "%x", $1);
+                           }
                        }
                ;
 
@@ -761,21 +752,21 @@ Float             :       FLOAT           { $$= scanInt; }
 Integer                :       INTEGER         { $$= scanInt; }
                ;
 
-KeyName                :       KEYNAME         { $$= scanStr; scanStr= NULL; }
+KeyName                :       KEYNAME         { $$= strdup(scanBuf); }
                ;
 
-Ident          :       IDENT   { $$= XkbInternAtom(NULL,scanStr,False); }
-               |       DEFAULT { $$= XkbInternAtom(NULL,"default",False); }
+Ident          :       IDENT   { $$= XkbcInternAtom(scanBuf,False); }
+               |       DEFAULT { $$= XkbcInternAtom("default",False); }
                ;
 
-String         :       STRING  { $$= XkbInternAtom(NULL,scanStr,False); }
+String         :       STRING  { $$= XkbcInternAtom(scanBuf,False); }
                ;
 
 OptMapName     :       MapName { $$= $1; }
                |               { $$= NULL; }
                ;
 
-MapName                :       STRING  { $$= scanStr; scanStr= NULL; }
+MapName                :       STRING  { $$= strdup(scanBuf); }
                ;
 %%
 void
@@ -784,8 +775,8 @@ yyerror(const char *s)
     if (warningLevel>0) {
        (void)fprintf(stderr,"%s: line %d of %s\n",s,lineNum,
                                        (scanFile?scanFile:"(unknown)"));
-       if ((scanStr)&&(warningLevel>3))
-           (void)fprintf(stderr,"last scanned symbol is: %s\n",scanStr);
+       if ((warningLevel>3))
+           (void)fprintf(stderr,"last scanned symbol is: %s\n",scanBuf);
     }
     return;
 }