Handle EM_S390_OLD.
[deliverable/binutils-gdb.git] / binutils / rcparse.y
index 0ab87d2cf80103000836753aa70856833522c14a..b67338f9d0455ce0ce742df6d5e3922ce6152b9e 100644 (file)
@@ -1,5 +1,5 @@
 %{ /* rcparse.y -- parser for Windows rc files
-   Copyright 1997 Free Software Foundation, Inc.
+   Copyright 1997, 1998 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
    This file is part of GNU Binutils.
@@ -107,7 +107,7 @@ static unsigned long class;
 %token BEDIT HEDIT IEDIT
 %token FONT
 %token ICON
-%token LANGUAGE CHARACTERISTICS VERSION
+%token LANGUAGE CHARACTERISTICS VERSIONK
 %token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE
 %token MENUBARBREAK MENUBREAK
 %token MESSAGETABLE
@@ -122,6 +122,7 @@ static unsigned long class;
 %token <s> QUOTEDSTRING STRING
 %token <i> NUMBER
 %token <ss> SIZEDSTRING
+%token IGNORED_TOKEN
 
 %type <pacc> acc_entries
 %type <acc> acc_entry acc_event
@@ -135,11 +136,11 @@ static unsigned long class;
 %type <vervar> vertrans
 %type <res_info> suboptions memflags_move_discard memflags_move
 %type <memflags> memflag
-%type <id> id
+%type <id> id resref
 %type <il> exstyle parennumber
 %type <il> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
 %type <is> acc_options acc_option menuitem_flags menuitem_flag
-%type <s> optstringc file_name
+%type <s> optstringc file_name resname
 %type <i> sizednumexpr sizedposnumexpr
 
 %left '|'
@@ -167,6 +168,7 @@ input:
        | input newcmd stringtable
        | input newcmd user
        | input newcmd versioninfo
+       | input newcmd IGNORED_TOKEN
        ;
 
 newcmd:
@@ -221,6 +223,9 @@ acc_entry:
            $$ = $1;
            $$.id = $2;
            $$.flags |= $4;
+           if (($$.flags & ACC_VIRTKEY) == 0
+               && ($$.flags & (ACC_SHIFT | ACC_CONTROL | ACC_ALT)) != 0)
+             rcparse_warning (_("inappropriate modifiers for non-VIRTKEY"));
          }
        ;
 
@@ -228,21 +233,27 @@ acc_event:
          QUOTEDSTRING
          {
            const char *s = $1;
+           char ch;
 
+           $$.next = NULL;
            $$.id = 0;
-           if (*s != '^')
+           ch = *s;
+           if (ch != '^')
              $$.flags = 0;
            else
              {
-               $$.flags = ACC_CONTROL;
+               $$.flags = ACC_CONTROL | ACC_VIRTKEY;
                ++s;
+               ch = *s;
+               ch = toupper ((unsigned char) ch);
              }
-           $$.key = *s;
+           $$.key = ch;
            if (s[1] != '\0')
-             rcparse_warning ("accelerator should only be one character");
+             rcparse_warning (_("accelerator should only be one character"));
          }
        | posnumexpr
          {
+           $$.next = NULL;
            $$.flags = 0;
            $$.id = 0;
            $$.key = $1;
@@ -258,6 +269,11 @@ acc_options:
          {
            $$ = $1 | $3;
          }
+       /* I've had one report that the comma is optional.  */
+       | acc_options acc_option
+         {
+           $$ = $1 | $2;
+         }
        ;
 
 acc_option:
@@ -422,7 +438,7 @@ styles:
            dialog.pointsize = $3;
            unicode_from_ascii ((int *) NULL, &dialog.font, $5);
            if (dialog.ex == NULL)
-             rcparse_warning ("extended FONT requires DIALOGEX");
+             rcparse_warning (_("extended FONT requires DIALOGEX"));
            else
              {
                dialog.ex->weight = $6;
@@ -441,7 +457,7 @@ styles:
          {
            sub_res_info.language = $3 | ($4 << 8);
          }
-       | styles VERSION numexpr
+       | styles VERSIONK numexpr
          {
            sub_res_info.version = $3;
          }
@@ -500,7 +516,7 @@ control:
          {
            $$ = $3;
            if (dialog.ex == NULL)
-             rcparse_warning ("IEDIT requires DIALOGEX");
+             rcparse_warning (_("IEDIT requires DIALOGEX"));
            res_string_to_id (&$$->class, "BEDIT");
          }
        | CHECKBOX
@@ -530,7 +546,7 @@ control:
            if ($11 != NULL)
              {
                if (dialog.ex == NULL)
-                 rcparse_warning ("control data requires DIALOGEX");
+                 rcparse_warning (_("control data requires DIALOGEX"));
                $$->data = $11;
              }
          }
@@ -539,10 +555,34 @@ control:
          {
            $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
            if (dialog.ex == NULL)
-             rcparse_warning ("help ID requires DIALOGEX");
+             rcparse_warning (_("help ID requires DIALOGEX"));
            $$->help = $11;
            $$->data = $12;
          }
+       | CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr
+           cnumexpr cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
+         {
+           $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
+           if ($12 != NULL)
+             {
+               if (dialog.ex == NULL)
+                 rcparse_warning ("control data requires DIALOGEX");
+               $$->data = $12;
+             }
+           $$->class.named = 1;
+           unicode_from_ascii(&$$->class.u.n.length, &$$->class.u.n.name, $5);
+         }
+       | CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr
+           cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
+         {
+           $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
+           if (dialog.ex == NULL)
+             rcparse_warning ("help ID requires DIALOGEX");
+           $$->help = $12;
+           $$->data = $13;
+           $$->class.named = 1;
+           unicode_from_ascii(&$$->class.u.n.length, &$$->class.u.n.name, $5);
+         }
        | CTEXT
            {
              default_style = SS_CENTER | WS_GROUP;
@@ -593,42 +633,32 @@ control:
          {
            $$ = $3;
            if (dialog.ex == NULL)
-             rcparse_warning ("IEDIT requires DIALOGEX");
+             rcparse_warning (_("IEDIT requires DIALOGEX"));
            res_string_to_id (&$$->class, "HEDIT");
          }
-       | ICON optstringc numexpr cnumexpr cnumexpr opt_control_data
-         {
-           $$ = define_control ($2, $3, $4, $5, 0, 0, CTL_STATIC,
-                                SS_ICON | WS_CHILD | WS_VISIBLE, 0);
-           if ($6 != NULL)
-             {
-               if (dialog.ex == NULL)
-                 rcparse_warning ("control data requires DIALOGEX");
-               $$->data = $6;
-             }
-         }
-       | ICON optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
+       | ICON resref numexpr cnumexpr cnumexpr opt_control_data
+          {
+           $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $6,
+                                     dialog.ex);
+          }
+       | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
+           opt_control_data
+          {
+           $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $8,
+                                     dialog.ex);
+          }
+       | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
            icon_styleexpr optcnumexpr opt_control_data
-         {
-           $$ = define_control ($2, $3, $4, $5, $6, $7, CTL_STATIC,
-                                style, $9);
-           if ($10 != NULL)
-             {
-               if (dialog.ex == NULL)
-                 rcparse_warning ("control data requires DIALOGEX");
-               $$->data = $10;
-             }
-         }
-       | ICON optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
+          {
+           $$ = define_icon_control ($2, $3, $4, $5, style, $9, 0, $10,
+                                     dialog.ex);
+          }
+       | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
            icon_styleexpr cnumexpr cnumexpr opt_control_data
-         {
-           $$ = define_control ($2, $3, $4, $5, $6, $7, CTL_STATIC,
-                                style, $9);
-           if (dialog.ex == NULL)
-             rcparse_warning ("help ID requires DIALOGEX");
-           $$->help = $10;
-           $$->data = $11;
-         }
+          {
+           $$ = define_icon_control ($2, $3, $4, $5, style, $9, $10, $11,
+                                     dialog.ex);
+          }
        | IEDIT
            {
              default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
@@ -639,7 +669,7 @@ control:
          {
            $$ = $3;
            if (dialog.ex == NULL)
-             rcparse_warning ("IEDIT requires DIALOGEX");
+             rcparse_warning (_("IEDIT requires DIALOGEX"));
            res_string_to_id (&$$->class, "IEDIT");
          }
        | LISTBOX
@@ -748,7 +778,7 @@ control_params:
            if ($7 != NULL)
              {
                if (dialog.ex == NULL)
-                 rcparse_warning ("control data requires DIALOGEX");
+                 rcparse_warning (_("control data requires DIALOGEX"));
                $$->data = $7;
              }
          }
@@ -759,7 +789,7 @@ control_params:
            if ($9 != NULL)
              {
                if (dialog.ex == NULL)
-                 rcparse_warning ("control data requires DIALOGEX");
+                 rcparse_warning (_("control data requires DIALOGEX"));
                $$->data = $9;
              }
          }
@@ -768,7 +798,7 @@ control_params:
          {
            $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
            if (dialog.ex == NULL)
-             rcparse_warning ("help ID requires DIALOGEX");
+             rcparse_warning (_("help ID requires DIALOGEX"));
            $$->help = $9;
            $$->data = $10;
          }
@@ -779,6 +809,10 @@ optstringc:
          {
            $$ = NULL;
          }
+       | QUOTEDSTRING
+         {
+           $$ = $1;
+         }
        | QUOTEDSTRING ','
          {
            $$ = $1;
@@ -974,6 +1008,10 @@ menuexitem:
          {
            $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
          }
+       | MENUITEM SEPARATOR
+         {
+           $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
+         }
        | POPUP QUOTEDSTRING BEG menuexitems END
          {
            $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
@@ -1221,8 +1259,46 @@ id:
            /* It seems that resource ID's are forced to upper case.  */
            copy = xstrdup ($1);
            for (s = copy; *s != '\0'; s++)
-             if (islower (*s))
-               *s = toupper (*s);
+             if (islower ((unsigned char) *s))
+               *s = toupper ((unsigned char) *s);
+           res_string_to_id (&$$, copy);
+           free (copy);
+         }
+       ;
+
+/* A resource reference.  */
+
+resname:
+         QUOTEDSTRING
+         {
+           $$ = $1;
+         }
+       | QUOTEDSTRING ','
+         {
+           $$ = $1;
+         }
+       | STRING ','
+         {
+           $$ = $1;
+         }
+       ;
+
+
+resref:
+         posnumexpr ','
+         {
+           $$.named = 0;
+           $$.u.id = $1;
+         }
+       | resname
+         {
+           char *copy, *s;
+
+           /* It seems that resource ID's are forced to upper case.  */
+           copy = xstrdup ($1);
+           for (s = copy; *s != '\0'; s++)
+             if (islower ((unsigned char) *s))
+               *s = toupper ((unsigned char) *s);
            res_string_to_id (&$$, copy);
            free (copy);
          }
@@ -1255,7 +1331,7 @@ suboptions:
            $$ = $1;
            $$.language = $3 | ($4 << 8);
          }
-       | suboptions VERSION numexpr
+       | suboptions VERSIONK numexpr
          {
            $$ = $1;
            $$.version = $3;
@@ -1288,7 +1364,7 @@ memflags_move:
            $$.language = language;
            $$.memflags = MEMFLAG_MOVEABLE;
          }
-       | memflags_move_discard memflag
+       | memflags_move memflag
          {
            $$ = $1;
            $$.memflags |= $2.on;
This page took 0.027576 seconds and 4 git commands to generate.