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 <dcw.h>
#include "struct.h"
declnlist build_declnlist( name, s, next ) char *name; shapelist s; declnlist next;
{
declnlist new = NEW( struct declnlist_str );
COPYOF( new->name, name );
new->shapes = s;
new->next = next;
return new;
}
void print_declnlist( d ) declnlist d;
{
for( ; d!=NULL; d=d->next ) {
Puts( d->name );
Puts( " = " );
shapelist build_shapelist( id, p, pl, next ) char *id; paramlist p; printlist pl; shapelist next;
void print_shape( s ) shapelist s;
{
Puts( s->name );
if( s->params )
{
Puts( "( " );
print_paramlist( s->params );
Puts( " )" );
}
putchar( ' ' );
print_printlist( s->pl );
}
Puts( "or " );
print_shape(s);
paramlist build_paramlist( type, id, next ) char *type, *id; paramlist next;
{
paramlist new = NEW( struct paramlist_str );
COPYOF( new->type, type );
COPYOF( new->name, id );
new->next = next;
return new;
}
void print_paramlist( p ) paramlist p;
if( p != NULL ) {
printf( "%s %s", p->type, p->name );
for( p=p->next; p!=NULL; p=p->next ) {
printf( ", %s %s", p->type, p->name );
}
printitem build_printitem_str( s ) char *s;
printitem new = NEW( struct printitem_str );
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
new->tag = printitem_is_str;
new->str = s;
return new;
}
printitem build_printitem_num( n ) int n;
{
printitem new = NEW( struct printitem_str );
new->tag = printitem_is_num;
new->num = n;
return new;
}
void print_printitem( i ) printitem i;
{
switch( i->tag )
{
case printitem_is_num:
printf( "%d ", i->num );
break;
case printitem_is_str:
printf( "\"%s\" ", i->str );
break;
default:
ABORT( ("datadec: print_printitem called with printitem tag = %d\n", i->tag ) );
}
}
printlist build_printlist( h, t ) printitem h; printlist t;
{
printlist new = NEW( struct printlist_str );
new->item = h;
new->next = t;
return new;
}
void print_printlist( p ) printlist p;
{
for( ; p!=NULL; p=p->next )
{
print_printitem( p->item );
}