annotate conv/c.c @ 702:8eadf0db2970

*** empty log message ***
author kono
date Tue, 23 Oct 2007 14:30:59 +0900
parents c9a489ac3fc7
children bf94c295d763
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
607
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
3 /************************************************************************
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
4 ** Copyright (C) 2006 Shinji Kono
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
5 ** 連絡先: 琉球大学情報工学科 河野 真治
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
6 ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp)
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
7 **
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
8 ** このソースのいかなる複写,改変,修正も許諾します。ただし、
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
9 ** その際には、誰が貢献したを示すこの部分を残すこと。
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
10 ** 再配布や雑誌の付録などの問い合わせも必要ありません。
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
11 ** 営利利用も上記に反しない範囲で許可します。
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
12 ** バイナリの配布の際にはversion messageを保存することを条件とします。
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
13 ** このプログラムについては特に何の保証もしない、悪しからず。
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
14 **
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
15 ** Everyone is permitted to do anything on this program
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
16 ** including copying, modifying, improving,
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
17 ** as long as you don't try to pretend that you wrote it.
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
18 ** i.e., the above copyright notice has to appear in all copies.
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
19 ** Binary distribution requires original version messages.
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
20 ** You don't have to ask before copying, redistribution or publishing.
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
21 ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
e055df7c1082 *** empty log message ***
kono
parents: 597
diff changeset
22 ***********************************************************************/
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 82
diff changeset
23 #include <stdio.h>
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
24 #include "mc.h"
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 82
diff changeset
25 #include "mc-parse.h"
597
756ba7c78e4c converter fix.
kono
parents: 564
diff changeset
26 #include "mc-codegen.h"
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
27
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 82
diff changeset
28 #include "conv/conv.h"
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
29 #include "conv/convdef.h"
82
25654dc29ecc First Floating Point coding done.
kono
parents: 79
diff changeset
30 #include "conv/c.h"
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
31
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
32 extern void type_print(int type,NMTBL *nptr,FILE *out);
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
33 extern void type_print1(int type,NMTBL *nptr,FILE *out,int cont);
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
34 extern void sym_print(int type,FILE *out);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
35
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
36 static FILE *vout,*svout;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
37 static FILE *null;
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
38
aa779bcffef7 CwC converters
kono
parents:
diff changeset
39 static void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
40 expr_(int c)
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
41 {
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
42 }
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
43
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
44 static void
651
c9a489ac3fc7 *** empty log message ***
kono
parents: 609
diff changeset
45 bool_(int c)
c9a489ac3fc7 *** empty log message ***
kono
parents: 609
diff changeset
46 {
c9a489ac3fc7 *** empty log message ***
kono
parents: 609
diff changeset
47 }
c9a489ac3fc7 *** empty log message ***
kono
parents: 609
diff changeset
48
c9a489ac3fc7 *** empty log message ***
kono
parents: 609
diff changeset
49 static void
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
50 comment_(int c)
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
51 {
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
52 fprintf(vout,"%c",c);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
53 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
54
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
55 static void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
56 open_(char *s)
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
57 {
346
969089695850 name reconfigure.... continue...
kono
parents: 327
diff changeset
58 char *p;
564
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
59 p = make_filename_with_extension(s,"cc");
77
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
60 #if 1
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
61 vout = fopen(p,"w");
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
62 #else
dba8d111b7a0 c output
kono
parents: 68
diff changeset
63 vout = stderr;p=p;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
64 #endif
dba8d111b7a0 c output
kono
parents: 68
diff changeset
65 null=fopen("/dev/null","w");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
66 if (!vout) error(-1);
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
67 }
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
68
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
69 static void
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
70 conv_()
dba8d111b7a0 c output
kono
parents: 68
diff changeset
71 {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
72 vout=svout;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
73 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
74
dba8d111b7a0 c output
kono
parents: 68
diff changeset
75 static void
dba8d111b7a0 c output
kono
parents: 68
diff changeset
76 noconv_(int c)
dba8d111b7a0 c output
kono
parents: 68
diff changeset
77 {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
78 svout=vout;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
79 vout=c?null:vout;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
80 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
81
dba8d111b7a0 c output
kono
parents: 68
diff changeset
82 static void
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
83 print_(char *s)
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
84 {
aa779bcffef7 CwC converters
kono
parents:
diff changeset
85 fprintf(vout,"c: %s\n",s);
aa779bcffef7 CwC converters
kono
parents:
diff changeset
86 }
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
87
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
88 static void
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
89 close_()
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
90 {
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
91 fclose(vout);
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
92 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
93
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
94 void
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
95 case_begin_(int cases,int def){
254a0c576114 argument type list
kono
parents: 66
diff changeset
96 fprintf(vout,"case ");
254a0c576114 argument type list
kono
parents: 66
diff changeset
97 }
254a0c576114 argument type list
kono
parents: 66
diff changeset
98
254a0c576114 argument type list
kono
parents: 66
diff changeset
99 void
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
100 case_(int cases,int def){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
101 if (def)
254a0c576114 argument type list
kono
parents: 66
diff changeset
102 fprintf(vout,"default:");
254a0c576114 argument type list
kono
parents: 66
diff changeset
103 else
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
104 fprintf(vout,"%d:",car(cases));
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
105 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
106
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
107 void
79
82d0e30f61dd *** empty log message ***
kono
parents: 77
diff changeset
108 code_(NMTBL *n){
82d0e30f61dd *** empty log message ***
kono
parents: 77
diff changeset
109 int args;
82d0e30f61dd *** empty log message ***
kono
parents: 77
diff changeset
110 args=n->dsp;
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
111 fprintf(vout,"code %s(",n->nm);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
112 while(args) {
79
82d0e30f61dd *** empty log message ***
kono
parents: 77
diff changeset
113 n=(NMTBL *)caddr(args);
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
114 type_print(n->ty,n,vout);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
115 args=cadr(args);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
116 if(args) fprintf(vout,",");
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
117 }
597
756ba7c78e4c converter fix.
kono
parents: 564
diff changeset
118 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
119 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
120
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
121 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
122 code_end_(){
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
123 fprintf(vout,"}");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
124 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
125
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
126 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
127 comma_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
128 fprintf(vout,",");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
129 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
130
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
131 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
132 cond_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
133
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
134 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
135
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
136 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
137 cond1_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
138 fprintf(vout,"?");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
139 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
140
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
141 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
142 cond2_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
143 fprintf(vout,":");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
144 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
145
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
146 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
147 cond_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
148
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
149 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
150
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
151 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
152 decl_data_begin_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
153
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
154 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
155
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
156 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
157 decl_data_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
158
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
159 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
160
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
161 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
162 def_(NMTBL *n){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
163 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
164
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
165 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
166 dowhile_(){
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
167 fprintf(vout,"do");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
168 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
169
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
170 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
171 dowhile_cond_(){
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
172 fprintf(vout,"while(");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
173 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
174
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
175 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
176 dowhile_end_(int cond){
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
177 fprintf(vout,");");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
178 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
179
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
180 int
468
464e7480395c *** empty log message ***
kono
parents: 348
diff changeset
181 error_(int n){
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
182 return 0;
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
183 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
184
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
185 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
186 extern_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
187 fprintf(vout,"extern ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
188 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
189
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
190 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
191 for_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
192 fprintf(vout,"for(");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
193 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
194
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
195 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
196 for1_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
197 fprintf(vout,";");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
198 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
199
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
200 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
201 for2_(int cond){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
202 fprintf(vout,";");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
203 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
204
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
205 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
206 for_body_(int conti){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
207 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
208 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
209
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
210 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
211 for_end_(int p0,int p1,int e){
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
212
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
213 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
214
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
215 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
216 funcall_(int type){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
217 fprintf(vout,"(");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
218 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
219
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
220 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
221 funcall_args_(int f, int t, int arg){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
222 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
223 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
224
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
225 void
79
82d0e30f61dd *** empty log message ***
kono
parents: 77
diff changeset
226 function_(NMTBL *n,int cont){
82d0e30f61dd *** empty log message ***
kono
parents: 77
diff changeset
227 int args;
564
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
228 type_print1(cadr(n->ty),0,vout,cont);
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
229 fprintf(vout,"%s(",n->nm);
79
82d0e30f61dd *** empty log message ***
kono
parents: 77
diff changeset
230 args=n->dsp;
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
231 while(args) {
79
82d0e30f61dd *** empty log message ***
kono
parents: 77
diff changeset
232 n=(NMTBL *)caddr(args);
597
756ba7c78e4c converter fix.
kono
parents: 564
diff changeset
233 if (n==&str_ret) { args=cadr(args); continue; }
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
234 type_print(n->ty,n,vout);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
235 args=cadr(args);
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
236 if(args) {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 82
diff changeset
237 /* if(caddr(args)==(int)&str_ret) break; */
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
238 fprintf(vout,",");
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
239 }
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
240 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
241 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
242 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
243
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
244 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
245 function_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
246
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
247 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
248
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
249 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
250 goto_(){
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
251 fprintf(vout,"goto ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
252 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
253
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
254 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
255 goto_label_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
256
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
257 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
258
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
259 void
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
260 id_(int sym,NMTBL *nptr){
564
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
261 char *p = nptr->nm;
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
262 for(;*p && *p!='.';p++) fputc(*p,vout);
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
263 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
264
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
265 void
348
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 346
diff changeset
266 string_(char *s,int len){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
267 int c;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
268 fprintf(vout,"\"");
dba8d111b7a0 c output
kono
parents: 68
diff changeset
269 while((c=*s++)) {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
270 if(c=='\n') fprintf(vout,"\\n");
dba8d111b7a0 c output
kono
parents: 68
diff changeset
271 else if(c=='\r') fprintf(vout,"\\r");
564
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
272 else if(c=='\t') fprintf(vout,"\\t");
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
273 else if(c=='\e') fprintf(vout,"\\e");
564
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
274 else if(c=='"') fprintf(vout,"\\\"");
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
275 else if(c=='\\') fprintf(vout,"\\\\");
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
276 else if(!(' '<=c&&c<=0x7f)) fprintf(vout,"\\%03o",c);
dba8d111b7a0 c output
kono
parents: 68
diff changeset
277 else fprintf(vout,"%c",c);
dba8d111b7a0 c output
kono
parents: 68
diff changeset
278 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
279 fprintf(vout,"\"");
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
280 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
281
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
282 void
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
283 const_(int symval){
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
284 fprintf(vout,"%d",symval);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
285 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
286
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
287 void
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
288 return_f_(){
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
289 fprintf(vout,"return");
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
290 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
291
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
292 void
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
293 defined_(char *s){
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
294 fprintf(vout,"defined(%s)",s);
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
295 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
296
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
297 void
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
298 environment_(){
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
299 fprintf(vout,"environment");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
300 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
301
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
302 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
303 if_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
304 fprintf(vout,"if (");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
305 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
306
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
307 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
308 if_else_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
309 fprintf(vout," else ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
310 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
311
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
312 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
313 if_endif_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
314 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
315
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
316 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
317 if_then_(int cond){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
318 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
319 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
320
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
321 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
322 jump_(int env){
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
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
326 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
327 label_(){
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
328 fprintf(vout,"%s:",nptr->nm);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
329 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
330
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
331 void
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
332 lpar_(){
254a0c576114 argument type list
kono
parents: 66
diff changeset
333 fprintf(vout,"(");
254a0c576114 argument type list
kono
parents: 66
diff changeset
334 }
254a0c576114 argument type list
kono
parents: 66
diff changeset
335
254a0c576114 argument type list
kono
parents: 66
diff changeset
336 void
254a0c576114 argument type list
kono
parents: 66
diff changeset
337 rpar_(){
254a0c576114 argument type list
kono
parents: 66
diff changeset
338 fprintf(vout,")");
254a0c576114 argument type list
kono
parents: 66
diff changeset
339 }
254a0c576114 argument type list
kono
parents: 66
diff changeset
340
254a0c576114 argument type list
kono
parents: 66
diff changeset
341 void
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
342 lbra_(int sym){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
343 fprintf(vout,"[");
254a0c576114 argument type list
kono
parents: 66
diff changeset
344 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
345
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
346 void
254a0c576114 argument type list
kono
parents: 66
diff changeset
347 rbra_(int sym){
254a0c576114 argument type list
kono
parents: 66
diff changeset
348 fprintf(vout,"]");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
349 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
350
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
351 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
352 lc_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
353 fprintf(vout,"{");
254a0c576114 argument type list
kono
parents: 66
diff changeset
354 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
355
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
356 void
254a0c576114 argument type list
kono
parents: 66
diff changeset
357 rc_(){
254a0c576114 argument type list
kono
parents: 66
diff changeset
358 fprintf(vout,"}");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
359 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
360
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
361 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
362 localvar_end_(){
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
363
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
364 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
365
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
366 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
367 op_(int sym){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
368 sym_print(sym,vout);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
369 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
370
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
371 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
372 postfix_(int sym){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
373 sym_print(sym,vout);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
374 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
375
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
376 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
377 prefix_(int sym){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
378 sym_print(sym,vout);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
379 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
380
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
381 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
382 register_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
383 fprintf(vout,"register ");
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 return_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
388 fprintf(vout,"return ");
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
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
392 return_end_(int e){
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
393 fprintf(vout,";");
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
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
397 return_type_(int t,NMTBL *nptr,int cont){
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
398 type_print1(t,nptr,vout,cont);
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 sm_(){
67
254a0c576114 argument type list
kono
parents: 66
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 static_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
408 fprintf(vout,"static ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
409 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
410
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
411 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
412 switch_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
413 fprintf(vout,"switch (");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
414 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
415
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
416 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
417 switch_body_(int v){
71
be313430f90b *** empty log message ***
kono
parents: 70
diff changeset
418 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
419 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
420
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
421 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
422 switch_end_(int cases){
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
423 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
424
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
425 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
426 typedef_(){
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
427 fprintf(vout,"typedef ");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
428 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
429
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
430 void
564
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
431 type_(int t){
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
432 type_print(t,0,vout);
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
433 }
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
434
25f431685d80 *** empty log message ***
kono
parents: 468
diff changeset
435 void
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
436 sdecl_(int s)
2e84590720a6 typedef name
kono
parents: 69
diff changeset
437 {
2e84590720a6 typedef name
kono
parents: 69
diff changeset
438 fprintf(vout,s==UNION?"union ":"struct ");
2e84590720a6 typedef name
kono
parents: 69
diff changeset
439 }
2e84590720a6 typedef name
kono
parents: 69
diff changeset
440
2e84590720a6 typedef name
kono
parents: 69
diff changeset
441 void
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
442 while_(){
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
443 fprintf(vout,"while (");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
444 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
445
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
446 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
447 while_body_(int cond){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
448 fprintf(vout,")");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
449 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
450
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
451 void
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
452 while_end_(){
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
453 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
454
dba8d111b7a0 c output
kono
parents: 68
diff changeset
455 void
dba8d111b7a0 c output
kono
parents: 68
diff changeset
456 decl_data_()
dba8d111b7a0 c output
kono
parents: 68
diff changeset
457 {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
458 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
459
dba8d111b7a0 c output
kono
parents: 68
diff changeset
460 void
dba8d111b7a0 c output
kono
parents: 68
diff changeset
461 break_()
dba8d111b7a0 c output
kono
parents: 68
diff changeset
462 {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
463 fprintf(vout,"break;");
dba8d111b7a0 c output
kono
parents: 68
diff changeset
464 }
dba8d111b7a0 c output
kono
parents: 68
diff changeset
465
dba8d111b7a0 c output
kono
parents: 68
diff changeset
466 void
dba8d111b7a0 c output
kono
parents: 68
diff changeset
467 continue_()
dba8d111b7a0 c output
kono
parents: 68
diff changeset
468 {
dba8d111b7a0 c output
kono
parents: 68
diff changeset
469 fprintf(vout,"continue;");
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
470 }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
471
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
472 /* end */