/* * 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. * ******* History * * Version Who Date Comments * ======= === ==== ======== * * 1.0 dcw 31st Dec 1987 Created * 1.1 dcw 1st Jan 1988 Recreated after screwup * 1.2 dcw 24th Apr 1989 Had a look again.. lowercased the lot */ #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 free_declnlist( d ) declnlist d; { declnlist temp; for( ; d!=NULL; d=temp ) { temp = d->next; free( d->name ); free_shapelist( d->shapes ); free( d ); } } void print_declnlist( d ) declnlist d; { for( ; d!=NULL; d=d->next ) { printf( "%s = ", d->name ); print_shapelist( d->shapes ); printf( "\n" ); } } shapelist build_shapelist( id, p, next ) char *id; paramlist p; shapelist next; { shapelist new = NEW( struct shapelist_str ); COPYOF( new->tagname, id ); new->params = p; new->next = next; return new; } void free_shapelist( s ) shapelist s; { shapelist temp; for( ; s!=NULL; s=temp ) { temp = s->next; free( s->tagname ); free_paramlist( s->params ); free( s ); } } void print_shapelist( s ) shapelist s; { if( s != NULL ) { printf( "%s( ", s->tagname ); print_paramlist( s->params ); printf( " )" ); for( s=s->next; s!=NULL; s=s->next ) { printf( " or %s( ", s->tagname ); print_paramlist( s->params ); printf( " )" ); } } } paramlist build_paramlist( type, stars, id, next ) char *type, *id; int stars; paramlist next; { paramlist new = NEW( struct paramlist_str ); COPYOF( new->type, type ); COPYOF( new->name, id ); new->stars = stars; new->next = next; return new; } void free_paramlist( p ) paramlist p; { paramlist temp; while( p!=NULL ) { temp = p->next; free( p->type ); free( p->name ); free( p ); p = temp; } } void print_paramlist( p ) paramlist p; { int i; if( p != NULL ) { printf( "%s ", p->type ); for( i= p->stars; i>0; i-- ) putchar( '*' ); printf( "%s", p->name ); for( p=p->next; p!=NULL; p=p->next ) { printf( ", %s ", p->type ); for( i= p->stars; i>0; i-- ) putchar( '*' ); printf( "%s", p->name ); } } }