ack/lang/m2/comp/misc.c

70 lines
1.5 KiB
C
Raw Normal View History

/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*
* Author: Ceriel J.H. Jacobs
*/
1986-03-26 15:11:02 +00:00
/* M I S C E L L A N E O U S R O U T I N E S */
1994-06-24 14:02:31 +00:00
/* $Id$ */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "alloc.h"
#include "em_arith.h"
#include "em_label.h"
1986-05-01 19:06:53 +00:00
#include "parameters.h"
1986-03-26 15:11:02 +00:00
#include "f_info.h"
#include "misc.h"
#include "LLlex.h"
#include "idf.h"
1986-04-08 18:15:46 +00:00
#include "node.h"
#include "error.h"
1986-03-26 15:11:02 +00:00
void match_id(register struct idf *id1, struct idf *id2)
1986-03-26 15:11:02 +00:00
{
/* Check that identifiers id1 and id2 are equal. If they
are not, check that we did'nt generate them in the
first place, and if not, give an error message
*/
if (id1 != id2 && !is_anon_idf(id1) && !is_anon_idf(id2)) {
1986-11-05 14:33:00 +00:00
error("name \"%s\" does not match block name \"%s\"",
1986-03-26 15:11:02 +00:00
id1->id_text,
id2->id_text
);
}
}
struct idf *gen_anon_idf(void)
1986-03-26 15:11:02 +00:00
{
/* A new idf is created out of nowhere, to serve as an
anonymous name.
*/
static int name_cnt;
1992-10-22 16:56:28 +00:00
char *s = Malloc(strlen(FileName)+50);
1986-04-03 17:41:26 +00:00
char *sprint();
1986-03-26 15:11:02 +00:00
1992-10-22 16:56:28 +00:00
sprint(s, "#%d in %s, line %u",
1986-03-26 15:11:02 +00:00
++name_cnt, FileName, LineNumber);
1992-10-22 16:56:28 +00:00
s = Realloc(s, strlen(s)+1);
return str2idf(s, 0);
1986-03-26 15:11:02 +00:00
}
1986-04-03 17:41:26 +00:00
void not_declared(char *what, struct node *id, char *where)
1986-04-03 17:41:26 +00:00
{
/* The identifier "id" is not declared. If it is not generated,
give an error message
*/
1986-04-08 18:15:46 +00:00
if (!is_anon_idf(id->nd_IDF)) {
node_error(id,
1986-10-22 15:38:24 +00:00
"%s \"%s\" not declared%s",
what,
id->nd_IDF->id_text,
where);
1986-04-03 17:41:26 +00:00
}
}