annotate conv/c2cbc.c @ 792:3622e3f561db

struct offset alignment
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 22 Nov 2010 14:14:15 +0900
parents bf94c295d763
children 5313ed059cee
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 ***********************************************************************/
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
23 #include <stdio.h>
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
24 #include "mc.h"
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
25 #include "mc-parse.h"
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
26 #include "mc-codegen.h"
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
27
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
28 #include "conv/conv.h"
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
29 #include "conv/convdef.h"
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
30 #include "conv/c2cbc.h"
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
31
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
32 extern void type_print(int type,NMTBL *nptr,FILE *out);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
33 extern void type_print1(int type,NMTBL *nptr,FILE *out,int cont);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
34 extern void sym_print(int type,FILE *out);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
35
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
36 static FILE *vout,*svout;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
37 static FILE *null;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
38 static FILE *hout;
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
39
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
40 static void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
41 expr_(int c)
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
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
45 static void
651
c9a489ac3fc7 *** empty log message ***
kono
parents: 609
diff changeset
46 bool_(int c)
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
c9a489ac3fc7 *** empty log message ***
kono
parents: 609
diff changeset
50 static void
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
51 comment_(int c)
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
52 {
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
53 fprintf(vout,"%c",c);
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
54 }
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
55
aa779bcffef7 CwC converters
kono
parents:
diff changeset
56 static void
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
57 open_(char *s)
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
58 {
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
59 char *p;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
60 p = make_filename_with_extension(s,"cbc.c");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
61 #if 1
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
62 vout = fopen(p,"w");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
63 #else
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
64 vout = stderr;p=p;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
65 #endif
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
66 p = make_filename_with_extension(s,"cbc.h");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
67 hout = fopen(p,"w");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
68 null=fopen("/dev/null","w");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
69 if (!vout) error(-1);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
70 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
71
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
72 static void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
73 conv_()
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
74 {
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
75 vout=svout;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
76 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
77
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
78 static void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
79 noconv_(int c)
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
80 {
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
81 svout=vout;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
82 vout=c?null:vout;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
83 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
84
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
85 static void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
86 print_(char *s)
60
aa779bcffef7 CwC converters
kono
parents:
diff changeset
87 {
aa779bcffef7 CwC converters
kono
parents:
diff changeset
88 fprintf(vout,"c: %s\n",s);
aa779bcffef7 CwC converters
kono
parents:
diff changeset
89 }
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
90
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
91 static void
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
92 close_()
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
93 {
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
94 fclose(vout);
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
95 }
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
96
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
97 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
98 case_begin_(int cases,int def){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
99 fprintf(vout,"case ");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
100 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
101
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
102 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
103 case_(int cases,int def){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
104 if (def)
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
105 fprintf(vout,"default:");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
106 else
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
107 fprintf(vout,"%d:",car(cases));
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
108 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
109
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
110 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
111 code_(NMTBL *n){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
112 int args;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
113 args=n->dsp;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
114 fprintf(vout,"code %s(",n->nm);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
115 while(args) {
712
bf94c295d763 *** empty log message ***
kono
parents: 651
diff changeset
116 n=ncadddr(args);
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
117 type_print(n->ty,n,vout);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
118 args=cadr(args);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
119 if(args) fprintf(vout,",");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
120 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
121 fprintf(vout,")");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
122 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
123
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
124 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
125 code_end_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
126 fprintf(vout,"}");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
127 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
128
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
129 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
130 comma_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
131 fprintf(vout,",");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
132 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
133
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
134 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
135 cond_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
136
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
137 }
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
138
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
139 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
140 cond1_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
141 fprintf(vout,"?");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
142 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
143
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
144 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
145 cond2_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
146 fprintf(vout,":");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
147 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
148
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
149 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
150 cond_end_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
151
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
152 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
153
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
154 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
155 decl_data_begin_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
156
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
157 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
158
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
159 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
160 decl_data_end_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
161
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
162 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
163
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
164 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
165 def_(NMTBL *n){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
166 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
167
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
168 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
169 dowhile_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
170 fprintf(vout,"do");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
171 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
172
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
173 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
174 dowhile_cond_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
175 fprintf(vout,"while(");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
176 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
177
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
178 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
179 dowhile_end_(int cond){
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
180 fprintf(vout,");");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
181 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
182
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
183 int
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
184 error_(int n){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
185 return 0;
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
186 }
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
187
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
188 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
189 extern_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
190 fprintf(vout,"extern ");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
191 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
192
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
193 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
194 for_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
195 fprintf(vout,"for(");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
196 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
197
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
198 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
199 for1_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
200 fprintf(vout,";");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
201 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
202
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
203 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
204 for2_(int cond){
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
205 fprintf(vout,";");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
206 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
207
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
208 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
209 for_body_(int conti){
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
210 fprintf(vout,")");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
211 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
212
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
213 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
214 for_end_(int p0,int p1,int e){
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
215
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
216
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
217 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
218
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
219 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
220 funcall_(int type){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
221 fprintf(vout,"(");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
222 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
223
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
224 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
225 funcall_args_(int f, int t, int args){
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
226 fprintf(vout,")");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
227 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
228
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
229 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
230 function_(NMTBL *n,int cont){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
231 int args;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
232 type_print1(cadr(n->ty),0,vout,cont);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
233 fprintf(vout,"%s(",n->nm);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
234 args=n->dsp;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
235 while(args) {
712
bf94c295d763 *** empty log message ***
kono
parents: 651
diff changeset
236 n=ncadddr(args);
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
237 if (n==&str_ret) {
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
238 args=cadr(args); continue;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
239 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
240 type_print(n->ty,n,vout);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
241 args=cadr(args);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
242 if(args) {
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
243 /* if(caddr(args)==(int)&str_ret) break; */
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
244 fprintf(vout,",");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
245 }
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
246 }
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
247 fprintf(vout,")");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
248 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
249
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
250 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
251 function_end_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
252
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
253 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
254
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
255 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
256 goto_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
257 fprintf(vout,"goto ");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
258 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
259
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
260 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
261 goto_label_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
262
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
263 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
264
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
265 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
266 id_(int sym,NMTBL *nptr){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
267 char *p = nptr->nm;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
268 for(;*p && *p!='.';p++) fputc(*p,vout);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
269 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
270
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
271 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
272 string_(char *s,int len){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
273 int c;
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
274 fprintf(vout,"\"");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
275 while((c=*s++)) {
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
276 if(c=='\n') fprintf(vout,"\\n");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
277 else if(c=='\r') fprintf(vout,"\\r");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
278 else if(c=='\t') fprintf(vout,"\\t");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
279 else if(c=='\e') fprintf(vout,"\\e");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
280 else if(c=='"') fprintf(vout,"\\\"");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
281 else if(c=='\\') fprintf(vout,"\\\\");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
282 else if(!(' '<=c&&c<=0x7f)) fprintf(vout,"\\%03o",c);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
283 else fprintf(vout,"%c",c);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
284 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
285 fprintf(vout,"\"");
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
286 }
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
287
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
288 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
289 const_(int symval){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
290 fprintf(vout,"%d",symval);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
291 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
292
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
293 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
294 return_f_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
295 fprintf(vout,"return");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
296 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
297
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
298 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
299 defined_(char *s){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
300 fprintf(vout,"defined(%s)",s);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
301 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
302
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
303 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
304 environment_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
305 fprintf(vout,"environment");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
306 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
307
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
308 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
309 if_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
310 fprintf(vout,"if (");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
311 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
312
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
313 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
314 if_else_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
315 fprintf(vout," else ");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
316 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
317
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
318 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
319 if_endif_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
320 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
321
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
322 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
323 if_then_(int cond){
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
324 fprintf(vout,")");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
325 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
326
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
327 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
328 jump_(int env){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
329
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
330 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
331
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
332 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
333 label_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
334 fprintf(vout,"%s:",nptr->nm);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
335 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
336
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
337 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
338 lpar_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
339 fprintf(vout,"(");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
340 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
341
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
342 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
343 rpar_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
344 fprintf(vout,")");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
345 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
346
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
347 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
348 lbra_(int sym){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
349 fprintf(vout,"[");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
350 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
351
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
352 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
353 rbra_(int sym){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
354 fprintf(vout,"]");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
355 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
356
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
357 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
358 lc_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
359 fprintf(vout,"{");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
360 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
361
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
362 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
363 rc_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
364 fprintf(vout,"}");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
365 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
366
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
367 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
368 localvar_end_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
369
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
370 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
371
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
372 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
373 op_(int sym){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
374 sym_print(sym,vout);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
375 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
376
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
377 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
378 postfix_(int sym){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
379 sym_print(sym,vout);
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
380 }
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
381
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
382 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
383 prefix_(int sym){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
384 sym_print(sym,vout);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
385 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
386
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
387 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
388 register_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
389 fprintf(vout,"register ");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
390 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
391
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
392 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
393 return_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
394 fprintf(vout,"return ");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
395 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
396
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
397 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
398 return_end_(int e){
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
399 fprintf(vout,";");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
400 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
401
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
402 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
403 return_type_(int t,NMTBL *nptr,int cont){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
404 type_print1(t,nptr,vout,cont);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
405 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
406
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
407 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
408 sm_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
409 fprintf(vout,";");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
410 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
411
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
412 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
413 static_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
414 fprintf(vout,"static ");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
415 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
416
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
417 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
418 switch_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
419 fprintf(vout,"switch (");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
420 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
421
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
422 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
423 switch_body_(int v){
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
424 fprintf(vout,")");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
425 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
426
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
427 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
428 switch_end_(int cases){
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
429 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
430
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
431 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
432 typedef_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
433 fprintf(vout,"typedef ");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
434 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
435
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
436 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
437 type_(int t){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
438 type_print(t,0,vout);
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
439 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
440
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
441 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
442 sdecl_(int s)
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
443 {
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
444 fprintf(vout,s==UNION?"union ":"struct ");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
445 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
446
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
447 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
448 while_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
449 fprintf(vout,"while (");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
450 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
451
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
452 void
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
453 while_body_(int cond){
597
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
454 fprintf(vout,")");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
455 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
456
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
457 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
458 while_end_(){
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
459 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
460
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
461 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
462 decl_data_()
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
463 {
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
464 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
465
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
466 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
467 break_()
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
468 {
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
469 fprintf(vout,"break;");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
470 }
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
471
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
472 void
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
473 continue_()
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
474 {
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
475 fprintf(vout,"continue;");
756ba7c78e4c converter fix.
kono
parents: 66
diff changeset
476 }
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
477
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
478
65
8ad746efa4f8 *** empty log message ***
kono
parents: 60
diff changeset
479 /* end */