RS/6000 portability changes (for hosting cross-debuggers).
[deliverable/binutils-gdb.git] / gdb / m2-exp.y
index ab0cb9e25428f4b58620f8ec1d073f9808960b50..73e08553066bfeb306077c3bf7456e4ae05545b9 100644 (file)
@@ -39,9 +39,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "language.h"
 #include "value.h"
 #include "parser-defs.h"
+#include "bfd.h"
+#include "symfile.h"
+#include "objfiles.h"
 
-/* These MUST be included in any grammar file!!!!
-   Please choose unique names! */
+/* These MUST be included in any grammar file!!!! Please choose unique names!
+   Note that this are a combined list of variables that can be produced
+   by any one of bison, byacc, or yacc. */
 #define        yymaxdepth m2_maxdepth
 #define        yyparse m2_parse
 #define        yylex   m2_lex
@@ -69,9 +73,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define        yy_yyv  m2_yyv
 #define        yyval   m2_val
 #define        yylloc  m2_lloc
+#define yyss   m2_yyss         /* byacc */
+#define        yyssp   m2_yysp         /* byacc */
+#define        yyvs    m2_yyvs         /* byacc */
+#define        yyvsp   m2_yyvsp        /* byacc */
 
+#if 0
 static char *
 make_qualname PARAMS ((char *, char *));
+#endif
 
 static int
 parse_number PARAMS ((int));
@@ -82,9 +92,6 @@ yylex PARAMS ((void));
 static void
 yyerror PARAMS ((char *));
 
-static void
-__yy_bcopy PARAMS ((char *, char *, int));
-
 int
 yyparse PARAMS ((void));
 
@@ -96,7 +103,6 @@ int number_sign = 1;
 struct block *modblock=0;
 
 /* #define     YYDEBUG 1 */
-
 %}
 
 /* Although the yacc "value" of an expression is not used,
@@ -127,7 +133,7 @@ struct block *modblock=0;
 %type <sym> fblock 
 
 %token <lval> INT HEX ERROR
-%token <ulval> UINT TRUE FALSE CHAR
+%token <ulval> UINT M2_TRUE M2_FALSE CHAR
 %token <dval> FLOAT
 
 /* Both NAME and TYPENAME tokens represent symbols in the input,
@@ -170,6 +176,19 @@ struct block *modblock=0;
 /* This is not an actual token ; it is used for precedence. 
 %right QID
 */
+
+%{
+/* Ensure that if the generated parser contains any calls to malloc/realloc,
+   that they get mapped to xmalloc/xrealloc.  We have to do this here
+   rather than earlier in the file because this is the first point after
+   the place where the SVR4 yacc includes <malloc.h>, and if we do it
+   before that, then the remapped declarations in <malloc.h> will collide
+   with the ones in "defs.h". */
+
+#define malloc xmalloc
+#define realloc        xrealloc
+%}
+
 %%
 
 start   :      exp
@@ -446,13 +465,13 @@ exp       :       exp ASSIGN exp
 
 /* Constants */
 
-exp    :       TRUE
+exp    :       M2_TRUE
                        { write_exp_elt_opcode (OP_BOOL);
                          write_exp_elt_longcst ((LONGEST) $1);
                          write_exp_elt_opcode (OP_BOOL); }
        ;
 
-exp    :       FALSE
+exp    :       M2_FALSE
                        { write_exp_elt_opcode (OP_BOOL);
                          write_exp_elt_longcst ((LONGEST) $1);
                          write_exp_elt_opcode (OP_BOOL); }
@@ -777,11 +796,11 @@ static struct
    int token;
 } tokentab2[] =
 {
-    {"<>",    NOTEQUAL          },
-    {":=",    ASSIGN    },
-    {"<=",    LEQ       },
-    {">=",    GEQ       },
-    {"::",    COLONCOLON },
+    { {'<', '>'},    NOTEQUAL  },
+    { {':', '='},    ASSIGN    },
+    { {'<', '='},    LEQ       },
+    { {'>', '='},    GEQ       },
+    { {':', ':'},    COLONCOLON },
 
 };
 
@@ -965,7 +984,7 @@ yylex ()
          {
            char *err_copy = (char *) alloca (p - tokstart + 1);
 
-           bcopy (tokstart, err_copy, p - tokstart);
+           memcpy (err_copy, tokstart, p - tokstart);
            err_copy[p - tokstart] = 0;
            error ("Invalid number \"%s\".", err_copy);
          }
@@ -1121,12 +1140,12 @@ yylex ()
        if(!strncmp(tokstart,"TRUE",4))
        {
          yylval.ulval = 1;
-         return TRUE;
+         return M2_TRUE;
        }
        else if(!strncmp(tokstart,"FALSE",5))
        {
          yylval.ulval = 0;
-         return FALSE;
+         return M2_FALSE;
        }
     }
 
@@ -1135,6 +1154,7 @@ yylex ()
  }
 }
 
+#if 0          /* Unused */
 static char *
 make_qualname(mod,ident)
    char *mod, *ident;
@@ -1146,7 +1166,7 @@ make_qualname(mod,ident)
    strcat(new,ident);
    return new;
 }
-
+#endif  /* 0 */
 
 static void
 yyerror(msg)
@@ -1224,24 +1244,26 @@ const struct language_defn m2_language_defn = {
 void
 _initialize_m2_exp ()
 {
-  /* FIXME:  The code below assumes that the sizes of the basic data
-     types are the same on the host and target machines!!!  */
-
   /* Modula-2 "pervasive" types.  NOTE:  these can be redefined!!! */
   builtin_type_m2_int =
-    init_type (TYPE_CODE_INT, sizeof(int), 0,
+    init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
+              0,
               "INTEGER", (struct objfile *) NULL);
   builtin_type_m2_card =
-    init_type (TYPE_CODE_INT, sizeof(int), TYPE_FLAG_UNSIGNED,
+    init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
+              TYPE_FLAG_UNSIGNED,
               "CARDINAL", (struct objfile *) NULL);
   builtin_type_m2_real =
-    init_type (TYPE_CODE_FLT, sizeof(float), 0,
+    init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
+              0,
               "REAL", (struct objfile *) NULL);
   builtin_type_m2_char =
-    init_type (TYPE_CODE_CHAR, sizeof(char), TYPE_FLAG_UNSIGNED,
+    init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+              TYPE_FLAG_UNSIGNED,
               "CHAR", (struct objfile *) NULL);
   builtin_type_m2_bool =
-    init_type (TYPE_CODE_BOOL, sizeof(int), TYPE_FLAG_UNSIGNED,
+    init_type (TYPE_CODE_BOOL, TARGET_INT_BIT / TARGET_CHAR_BIT,
+              TYPE_FLAG_UNSIGNED,
               "BOOLEAN", (struct objfile *) NULL);
 
   TYPE_NFIELDS(builtin_type_m2_bool) = 2;
This page took 0.030922 seconds and 4 git commands to generate.