Use CARD32 instead of Atom, move geom headers in
[platform/upstream/libxkbcommon.git] / src / xkbcomp / xkbparse.y
index 1395b2c..ae37f7a 100644 (file)
@@ -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/XKBgeomcommon.h>
 #include <stdlib.h>
 
 unsigned int parseDebug;
@@ -136,9 +137,9 @@ 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 <str>    KeyName MapName OptMapName KeySym
 %type <sval>   FieldSpec Ident Element String
 %type <any>    DeclList Decl
 %type <expr>   OptExprList ExprList Expr Term Lhs Terminal ArrayInit
@@ -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;
                            }
                         }
                ;
@@ -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
@@ -716,35 +717,25 @@ OptKeySymList     :       KeySymList                      { $$= $1; }
                ;
 
 KeySymList     :       KeySymList COMMA KeySym
-                       { $$= AppendKeysymList($1,(KeySym)$3); }
+                       { $$= AppendKeysymList($1,$3); }
                |       KeySym
-                       { $$= CreateKeysymList((KeySym)$1); }
+                       { $$= CreateKeysymList($1); }
                ;
 
-KeySym         :       IDENT
+KeySym         :       IDENT   { $$= strdup(scanBuf); }
+               |       SECTION { $$= strdup("section"); }
+               |       Integer         
                        {
-                           KeySym sym;
-                           if (LookupKeysym(scanStr,&sym))
-                               $$= sym;
+                           if ($1 < 10) {      /* XK_0 .. XK_9 */
+                               $$= malloc(2);
+                               $$[0]= $1 + '0';
+                               $$[1]= '\0';
+                           }
                            else {
-                               char buf[120];
-                               snprintf(buf, sizeof(buf),
-                                        "expected keysym, got %s",
-                                        uStringText(scanStr));
-                               yyerror(buf);
-                               yynerrs++;
-                               $$= NoSymbol;
+                               $$= malloc(17);
+                               snprintf($$, 17, "%x", $1);
                            }
                        }
-               |       SECTION
-                       {
-                           $$= XK_section;
-                       }
-               |       Integer         
-                       {
-                           if ($1<10)  $$= $1+'0';     /* XK_0 .. XK_9 */
-                           else        $$= $1;
-                       }
                ;
 
 SignedNumber   :       MINUS Number    { $$= -$2; }
@@ -761,21 +752,21 @@ Float             :       FLOAT           { $$= scanInt; }
 Integer                :       INTEGER         { $$= scanInt; }
                ;
 
-KeyName                :       KEYNAME         { $$= scanStr; scanStr= NULL; }
+KeyName                :       KEYNAME         { $$= strdup(scanBuf); }
                ;
 
-Ident          :       IDENT   { $$= XkbcInternAtom(scanStr,False); }
+Ident          :       IDENT   { $$= XkbcInternAtom(scanBuf,False); }
                |       DEFAULT { $$= XkbcInternAtom("default",False); }
                ;
 
-String         :       STRING  { $$= XkbcInternAtom(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;
 }