Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
/*
* 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 );
}
}
}