#include "symfile.h"
#include "objfiles.h"
-/* Ensure that if the generated parser contains any calls to malloc/realloc,
- that they get mapped to xmalloc/xrealloc. */
-
-#define malloc xmalloc
-#define realloc xrealloc
-
-/* 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
#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 *
/* #define YYDEBUG 1 */
+/* !@&%ing AIX defines these! Prevent cpp complaints by undeffing them */
+#undef TRUE
+#undef FALSE
%}
/* Although the yacc "value" of an expression is not used,
*/
%%
+%{
+/* 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
| type_exp
;
int token;
} tokentab2[] =
{
- {"<>", NOTEQUAL },
- {":=", ASSIGN },
- {"<=", LEQ },
- {">=", GEQ },
- {"::", COLONCOLON },
+ { {'<', '>'}, NOTEQUAL },
+ { {':', '='}, ASSIGN },
+ { {'<', '='}, LEQ },
+ { {'>', '='}, GEQ },
+ { {':', ':'}, COLONCOLON },
};
{
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);
}
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;