annotate conv/c.c @ 72:3b5d293cea36

type def etc
author kono
date Mon, 24 Feb 2003 16:04:30 +0900
parents be313430f90b
children 6de658ae384c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
1 #define EXTERN /**/
aa779bcffef7 CwC converters
kono
parents:
diff changeset
2
aa779bcffef7 CwC converters
kono
parents:
diff changeset
3 #include "mc.h"
aa779bcffef7 CwC converters
kono
parents:
diff changeset
4
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
5 #include "conv/convdef.h"
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
6
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
7 extern void type_print(int type,NMTBL *nptr,FILE *out);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
8 extern void sym_print(int type,FILE *out);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
9
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
10 static FILE *vout,*svout;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
11 static FILE *null;
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
12
aa779bcffef7 CwC converters
kono
parents:
diff changeset
13 static void
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
14 comment_(int c)
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
15 {
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
16 fprintf(vout,"%c",c);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
17 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
18
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
19 static void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
20 open_(char *s)
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
21 {
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
22 char *p=cheapp;
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
23 while ((*cheapp++ = *s++)) {
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
24 if (*s=='.') {
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
25 *cheapp++=*s++; *cheapp++='c';
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
26 *cheapp++='c'; *cheapp++=0;
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
27 break;
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
28 }
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
29 }
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
30 #if 1
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
31 vout = fopen(p,"w");
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
32 #else
dba8d111b7a0 c output
kono
parents: 68
diff changeset
33 vout = stderr;p=p;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
34 #endif
dba8d111b7a0 c output
kono
parents: 68
diff changeset
35 null=fopen("/dev/null","w");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
36 if (!vout) error(-1);
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
37 }
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
38
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
39 static void
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
40 conv_()
dba8d111b7a0 c output
kono
parents: 68
diff changeset
41 {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
42 vout=svout;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
43 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
44
dba8d111b7a0 c output
kono
parents: 68
diff changeset
45 static void
dba8d111b7a0 c output
kono
parents: 68
diff changeset
46 noconv_(int c)
dba8d111b7a0 c output
kono
parents: 68
diff changeset
47 {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
48 svout=vout;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
49 vout=c?null:vout;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
50 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
51
dba8d111b7a0 c output
kono
parents: 68
diff changeset
52 static void
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
53 print_(char *s)
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
54 {
aa779bcffef7 CwC converters
kono
parents:
diff changeset
55 fprintf(vout,"c: %s\n",s);
aa779bcffef7 CwC converters
kono
parents:
diff changeset
56 }
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
57
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
58 static void
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
59 close_()
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
60 {
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
61 fclose(vout);
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
62 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
63
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
64 void
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
65 case_begin_(int cases,int def){
254a0c576114 argument type list
kono
parents: 66
diff changeset
66 fprintf(vout,"case ");
254a0c576114 argument type list
kono
parents: 66
diff changeset
67 }
254a0c576114 argument type list
kono
parents: 66
diff changeset
68
254a0c576114 argument type list
kono
parents: 66
diff changeset
69 void
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
70 case_(int cases,int def){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
71 if (def)
254a0c576114 argument type list
kono
parents: 66
diff changeset
72 fprintf(vout,"default:");
254a0c576114 argument type list
kono
parents: 66
diff changeset
73 else
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
74 fprintf(vout,"%d:",car(cases));
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
75 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
76
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
77 void
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
78 code_(NMTBL *n,int arglist){
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
79 fprintf(vout,"code %s(",n->nm);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
80 while(args) {
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
81 n=(NMTBL *)car(args);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
82 type_print(n->ty,n,vout);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
83 args=cadr(args);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
84 if(args) fprintf(vout,",");
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
85 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
86 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
87 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
88
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
89 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
90 code_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
91
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
92 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
93
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
94 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
95 comma_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
96 fprintf(vout,",");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
97 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
98
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
99 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
100 cond_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
101
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
102 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
103
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
104 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
105 cond1_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
106 fprintf(vout,"?");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
107 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
108
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
109 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
110 cond2_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
111 fprintf(vout,":");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
112 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
113
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
114 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
115 cond_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
116
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
117 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
118
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
119 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
120 decl_data_begin_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
121
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
122 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
123
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
124 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
125 decl_data_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
126
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
127 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
128
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
129 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
130 def_(NMTBL *n){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
131 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
132
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
133 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
134 dowhile_(){
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
135 fprintf(vout,"do");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
136 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
137
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
138 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
139 dowhile_cond_(){
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
140 fprintf(vout,"while(");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
141 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
142
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
143 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
144 dowhile_end_(){
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
145 fprintf(vout,");");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
146 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
147
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
148 int
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
149 error_(n){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
150 return 0;
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
151 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
152
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
153 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
154 extern_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
155 fprintf(vout,"extern ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
156 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
157
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
158 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
159 for_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
160 fprintf(vout,"for(");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
161 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
162
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
163 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
164 for1_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
165 fprintf(vout,";");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
166 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
167
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
168 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
169 for2_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
170 fprintf(vout,";");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
171 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
172
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
173 void
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
174 for_body_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
175 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
176 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
177
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
178 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
179 for_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
180
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
181 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
182
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
183 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
184 funcall_(int type){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
185 fprintf(vout,"(");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
186 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
187
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
188 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
189 funcall_args_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
190 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
191 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
192
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
193 void
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
194 function_(NMTBL *n,int args){
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
195 type_print(n->ty,0,vout);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
196 fprintf(vout,"%s(",n->nm);
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
197 args=reverse0(args);
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
198 while(args) {
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
199 n=(NMTBL *)car(args);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
200 type_print(n->ty,n,vout);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
201 args=cadr(args);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
202 if(args) fprintf(vout,",");
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
203 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
204 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
205 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
206
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
207 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
208 function_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
209
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
210 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
211
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
212 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
213 goto_(){
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
214 fprintf(vout,"goto");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
215 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
216
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
217 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
218 goto_label_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
219
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
220 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
221
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
222 void
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
223 id_(int sym,NMTBL *nptr){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
224 fprintf(vout,"%s",nptr->nm);
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
225 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
226
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
227 void
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
228 string_(char *s){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
229 int c;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
230 fprintf(vout,"\"");
dba8d111b7a0 c output
kono
parents: 68
diff changeset
231 while((c=*s++)) {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
232 if(c=='\n') fprintf(vout,"\\n");
dba8d111b7a0 c output
kono
parents: 68
diff changeset
233 else if(c=='\r') fprintf(vout,"\\r");
dba8d111b7a0 c output
kono
parents: 68
diff changeset
234 else if(c=='\e') fprintf(vout,"\\e");
dba8d111b7a0 c output
kono
parents: 68
diff changeset
235 else if(!(' '<=c&&c<=0x7f)) fprintf(vout,"\\%03o",c);
dba8d111b7a0 c output
kono
parents: 68
diff changeset
236 else fprintf(vout,"%c",c);
dba8d111b7a0 c output
kono
parents: 68
diff changeset
237 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
238 fprintf(vout,"\"");
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
239 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
240
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
241 void
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
242 const_(int symval){
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
243 fprintf(vout,"%d",symval);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
244 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
245
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
246 void
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
247 return_f_(){
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
248 fprintf(vout,"return");
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
249 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
250
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
251 void
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
252 defined_(char *s){
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
253 fprintf(vout,"defined(%s)",s);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
254 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
255
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
256 void
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
257 environment_(){
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
258 fprintf(vout,"environment");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
259 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
260
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
261 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
262 if_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
263 fprintf(vout,"if (");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
264 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
265
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
266 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
267 if_else_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
268 fprintf(vout," else ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
269 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
270
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
271 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
272 if_endif_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
273 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
274
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
275 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
276 if_then_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
277 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
278 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
279
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
280 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
281 jump_(int env){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
282
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
283 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
284
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
285 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
286 label_(){
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
287 fprintf(vout,"%s:",nptr->nm);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
288 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
289
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
290 void
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
291 lpar_(){
254a0c576114 argument type list
kono
parents: 66
diff changeset
292 fprintf(vout,"(");
254a0c576114 argument type list
kono
parents: 66
diff changeset
293 }
254a0c576114 argument type list
kono
parents: 66
diff changeset
294
254a0c576114 argument type list
kono
parents: 66
diff changeset
295 void
254a0c576114 argument type list
kono
parents: 66
diff changeset
296 rpar_(){
254a0c576114 argument type list
kono
parents: 66
diff changeset
297 fprintf(vout,")");
254a0c576114 argument type list
kono
parents: 66
diff changeset
298 }
254a0c576114 argument type list
kono
parents: 66
diff changeset
299
254a0c576114 argument type list
kono
parents: 66
diff changeset
300 void
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
301 lbra_(int sym){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
302 fprintf(vout,"[");
254a0c576114 argument type list
kono
parents: 66
diff changeset
303 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
304
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
305 void
254a0c576114 argument type list
kono
parents: 66
diff changeset
306 rbra_(int sym){
254a0c576114 argument type list
kono
parents: 66
diff changeset
307 fprintf(vout,"]");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
308 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
309
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
310 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
311 lc_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
312 fprintf(vout,"{");
254a0c576114 argument type list
kono
parents: 66
diff changeset
313 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
314
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
315 void
254a0c576114 argument type list
kono
parents: 66
diff changeset
316 rc_(){
254a0c576114 argument type list
kono
parents: 66
diff changeset
317 fprintf(vout,"}");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
318 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
319
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
320 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
321 localvar_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
322
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
323 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
324
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
325 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
326 op_(int sym){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
327 sym_print(sym,vout);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
328 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
329
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
330 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
331 postfix_(int sym){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
332 sym_print(sym,vout);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
333 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
334
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
335 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
336 prefix_(int sym){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
337 sym_print(sym,vout);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
338 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
339
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
340 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
341 register_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
342 fprintf(vout,"register ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
343 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
344
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
345 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
346 return_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
347 fprintf(vout,"return ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
348 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
349
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
350 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
351 return_end_(){
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
352 fprintf(vout,";");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
353 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
354
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
355 void
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
356 return_type_(int t,NMTBL *nptr,int cont){
254a0c576114 argument type list
kono
parents: 66
diff changeset
357 if (cont) {
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
358 /* type print に cont の機能を持たせるべきだよね
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
359 cont の場合は、配列/関数/ポインタまでは無視する(?)
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
360 (int(*)) a,*b; みたいな場合は? (えぇ?)
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
361 ってことは、context で、どこまで表示したかを覚えて
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
362 おく必要がある? もっとも自分で表示してしまった
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
363 はずだから、それを覚えていれば良いだけだけどね。
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
364 */
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
365 while (t>0&&car(t)==POINTER) {
2e84590720a6 typedef name
kono
parents: 69
diff changeset
366 fprintf(vout,"*");
2e84590720a6 typedef name
kono
parents: 69
diff changeset
367 t=cadr(t);
2e84590720a6 typedef name
kono
parents: 69
diff changeset
368 }
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
369 if(nptr) fprintf(vout,"%s",nptr->nm);
254a0c576114 argument type list
kono
parents: 66
diff changeset
370 while (t>0&&car(t)==ARRAY) {
254a0c576114 argument type list
kono
parents: 66
diff changeset
371 if(caddr(t)==0)
254a0c576114 argument type list
kono
parents: 66
diff changeset
372 fprintf(vout,"[]");
254a0c576114 argument type list
kono
parents: 66
diff changeset
373 else
254a0c576114 argument type list
kono
parents: 66
diff changeset
374 fprintf(vout,"[%d]",caddr(t));
254a0c576114 argument type list
kono
parents: 66
diff changeset
375 t=cadr(t);
254a0c576114 argument type list
kono
parents: 66
diff changeset
376 }
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
377 if (t>0&&car(t)==FUNCTION) {
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
378 fprintf(vout,"(");
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
379 type_print(cadr(t),0,vout);
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
380 fprintf(vout,")");
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
381 }
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
382 } else
254a0c576114 argument type list
kono
parents: 66
diff changeset
383 type_print(t,nptr,vout);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
384 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
385
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
386 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
387 sm_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
388 fprintf(vout,";");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
389 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
390
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
391 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
392 static_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
393 fprintf(vout,"static ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
394 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
395
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
396 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
397 switch_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
398 fprintf(vout,"switch (");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
399 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
400
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
401 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
402 switch_body_(){
71
be313430f90b *** empty log message ***
kono
parents: 70
diff changeset
403 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
404 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
405
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
406 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
407 switch_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
408 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
409
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
410 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
411 typedef_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
412 fprintf(vout,"typedef ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
413 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
414
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
415 void
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
416 sdecl_(int s)
2e84590720a6 typedef name
kono
parents: 69
diff changeset
417 {
2e84590720a6 typedef name
kono
parents: 69
diff changeset
418 fprintf(vout,s==UNION?"union ":"struct ");
2e84590720a6 typedef name
kono
parents: 69
diff changeset
419 }
2e84590720a6 typedef name
kono
parents: 69
diff changeset
420
2e84590720a6 typedef name
kono
parents: 69
diff changeset
421 void
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
422 while_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
423 fprintf(vout,"while (");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
424 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
425
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
426 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
427 while_body_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
428 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
429 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
430
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
431 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
432 while_end_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
433 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
434
dba8d111b7a0 c output
kono
parents: 68
diff changeset
435 void
dba8d111b7a0 c output
kono
parents: 68
diff changeset
436 decl_data_()
dba8d111b7a0 c output
kono
parents: 68
diff changeset
437 {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
438 fprintf(vout," = ");
dba8d111b7a0 c output
kono
parents: 68
diff changeset
439 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
440
dba8d111b7a0 c output
kono
parents: 68
diff changeset
441 void
dba8d111b7a0 c output
kono
parents: 68
diff changeset
442 break_()
dba8d111b7a0 c output
kono
parents: 68
diff changeset
443 {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
444 fprintf(vout,"break;");
dba8d111b7a0 c output
kono
parents: 68
diff changeset
445 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
446
dba8d111b7a0 c output
kono
parents: 68
diff changeset
447 void
dba8d111b7a0 c output
kono
parents: 68
diff changeset
448 continue_()
dba8d111b7a0 c output
kono
parents: 68
diff changeset
449 {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
450 fprintf(vout,"continue;");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
451 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
452
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
453 /* end */