Newer
Older
/*
* DATA STRUCTURES
* ==== ==========
*
* FOR THE
* === ===
*
* DATA DECLARATION BUILDER
* ==== =========== =======
*
* This module provides the internal structures needed
* for the data declaration builder. It is itself the
* sort of output generated by the program (although a
* bit optimized!)
#include <stdio.h>
#include <malloc.h>
#define NEW(t) (t) malloc( sizeof(struct t) )
#define COPYOF(new,old) {new=malloc(1+strlen(old));if(new)strcpy(new,old);}
declnlist build_declnlist(name,s,next) char *name; shapelist s; declnlist next;
for ( ; d; d = d->next)
{
Puts(d->name);
Puts(" = ");
print_shapelist(d->shapes);
putchar('\n');
shapelist build_shapelist(id, p, pl, next) char *id; paramlist p; printlist pl; shapelist next;
if (s != NULL)
{
print_shape(s);
for (s = s->next; s; s = s->next)
{
Puts("or ");
paramlist build_paramlist(type, id, next) char *type, *id; paramlist next;
if (p != NULL)
{
printf("%s %s", p->type, p->name);
for (p = p->next; p; p = p->next)
{
printf(", %s %s", p->type, p->name);
new->tag = printitem_is_str;
new->str = s;
return new;
}
new->tag = printitem_is_num;
new->num = n;
return new;
}
{
case printitem_is_num:
break;
case printitem_is_str:
fprintf( stderr,
"datadec: print_printitem called with tag = %d\n",
i->tag );
exit(1);
new->item = h;
new->next = t;
return new;
}
param findnthparam( n, p, sname, dname ) int n; paramlist p; char *sname, *dname;
{
int m = n;
for( ; p != NULL && --m; p = p->next );
if( p == NULL )
{
fprintf( stderr,
"datadec: bad print number %d in shape %s of type %s\n",
m, sname, dname );
exit(1);
}