source: dev/BasicCompiler_Common/CommandFormat.cpp@ 22

Last change on this file since 22 was 4, checked in by dai_9181, 18 years ago
File size: 7.1 KB
Line 
1#include "common.h"
2
3void ComOpen(char *Parameter,char *buffer,int NowLine){
4 int i,i2,IsStr;
5 char temporary[255];
6
7 for(i=0,i2=0,IsStr=0;;i++,i2++){
8 if(Parameter[i]=='\"') IsStr^=1;
9 if((
10 ((Parameter[i]==' '||Parameter[i]=='\t')&&(Parameter[i+1]=='f'||Parameter[i+1]=='F')&&(Parameter[i+2]=='o'||Parameter[i+2]=='O')&&(Parameter[i+3]=='r'||Parameter[i+3]=='R')&&(Parameter[i+4]==' '||Parameter[i+4]=='\t'))||
11 (Parameter[i]==1&&Parameter[i+1]==ESC_AS)
12 )&&IsStr==0){
13 buffer[i2]=0;
14 break;
15 }
16 buffer[i2]=Parameter[i];
17 if(Parameter[i]=='\0') return;
18 }
19
20 KillStringSpaces(buffer);
21
22 if(Parameter[i]==1&&Parameter[i+1]==ESC_AS) lstrcat(buffer,",0");
23 else{
24 i+=4;
25 while(Parameter[i]==' '||Parameter[i]=='\t') i++;
26 for(i2=0;;i++,i2++){
27 if(Parameter[i]=='\0'){
28 SetError(1,NULL,NowLine);
29 return;
30 }
31 if(Parameter[i]==' '||Parameter[i]=='\t'||(Parameter[i]==1&&Parameter[i+1]==ESC_AS)){
32 temporary[i2]=0;
33 break;
34 }
35 temporary[i2]=Parameter[i];
36 }
37 if(lstrcmpi(temporary,"input")==0) lstrcat(buffer,",1");
38 else if(lstrcmpi(temporary,"output")==0) lstrcat(buffer,",2");
39 else if(lstrcmpi(temporary,"append")==0) lstrcat(buffer,",3");
40 else{
41 SetError(1,NULL,NowLine);
42 return;
43 }
44
45 while(Parameter[i]==' '||Parameter[i]=='\t') i++;
46 if(!(Parameter[i]==1&&Parameter[i+1]==ESC_AS)) return;
47 }
48
49 i+=2;
50 while(Parameter[i]==' '||Parameter[i]=='\t') i++;
51 if(Parameter[i]=='#') i++;
52
53 lstrcat(buffer,",");
54 lstrcat(buffer,Parameter+i);
55}
56void ComClose(char *Parameter,char *buffer){
57 if(Parameter[0]=='#') lstrcpy(buffer,Parameter+1);
58 else lstrcpy(buffer,Parameter);
59}
60void ComField(char *Parameter,char *buffer){
61 if(Parameter[0]=='#') KillSpaces(Parameter+1,buffer);
62 else KillSpaces(Parameter,buffer);
63}
64
65void ComLine(char *Parameter,char *buffer,int NowLine){
66 int i,i2,PareNum;
67 char temporary[VN_SIZE],temp2[VN_SIZE];
68
69 KillStringSpaces(Parameter);
70
71 if(Parameter[0]=='-'){
72 lstrcpy(buffer,"&H80000000,&H80000000");
73 i=0;
74 }
75 else{
76 if(Parameter[0]!='('){
77 SetError(10,"Line",NowLine);
78 return;
79 }
80 for(i=1,i2=0,PareNum=1;;i++,i2++){
81 if(Parameter[i]=='(') PareNum++;
82 if(Parameter[i]==')'){
83 PareNum--;
84 if(PareNum==0){
85 temporary[i2]=0;
86 break;
87 }
88 }
89 temporary[i2]=Parameter[i];
90 }
91
92 lstrcpy(buffer,temporary);
93
94 if(Parameter[i+1]!='-'){
95 SetError(10,"Line",NowLine);
96 return;
97 }
98 i++;
99 }
100
101 i++;
102 if((Parameter[i]=='s'||Parameter[i]=='S')&&(Parameter[i+1]=='t'||Parameter[i+1]=='T')&&(Parameter[i+2]=='e'||Parameter[i+2]=='E')&&(Parameter[i+3]=='p'||Parameter[i+3]=='P')){
103 lstrcat(buffer,",1,");
104 i+=4;
105 }
106 else lstrcat(buffer,",0,");
107
108 if(Parameter[i]!='('){
109 SetError(10,"Line",NowLine);
110 return;
111 }
112 for(i++,i2=0,PareNum=1;;i++,i2++){
113 if(Parameter[i]=='(') PareNum++;
114 if(Parameter[i]==')'){
115 PareNum--;
116 if(PareNum==0){
117 temporary[i2]=0;
118 break;
119 }
120 }
121 temporary[i2]=Parameter[i];
122 }
123
124 lstrcat(buffer,temporary);
125
126 if(Parameter[i+1]=='\0'){
127 lstrcat(buffer,",7");
128 return;
129 }
130 else if(Parameter[i+1]!=','){
131 SetError(10,"Line",NowLine);
132 return;
133 }
134 i+=2;
135
136 i=GetOneParameter(Parameter,i,temporary); //第5パラメータ取得
137 if(temporary[0]=='\0')
138 lstrcpy(temporary,"7");
139 lstrcat(buffer,",");
140 lstrcat(buffer,temporary);
141 lstrcpy(temp2,temporary);
142
143 if(Parameter[i]=='\0') return;
144 i=GetOneParameter(Parameter,i,temporary); //第6パラメータ取得
145 if(temporary[0]=='\0') lstrcat(buffer,",0");
146 else if(lstrcmpi(temporary,"b")==0) lstrcat(buffer,",1");
147 else if(lstrcmpi(temporary,"bf")==0) lstrcat(buffer,",2");
148 else{
149 SetError(10,"Line",NowLine);
150 return;
151 }
152
153 if(Parameter[i]=='\0'){
154 lstrcat(buffer,",");
155 lstrcat(buffer,temp2);
156 return;
157 }
158 i=GetOneParameter(Parameter,i,temporary); //第7パラメータ取得
159 if(Parameter[i-1]==','){
160 SetError(10,"Line",NowLine);
161 return;
162 }
163 if(temporary[0]=='\0') lstrcpy(temporary,temp2);
164 lstrcat(buffer,",");
165 lstrcat(buffer,temporary);
166}
167void ComCircle(char *Parameter,char *buffer,int NowLine){
168 int i,i2,PareNum;
169 char temporary[VN_SIZE],temp2[VN_SIZE];
170
171 KillStringSpaces(Parameter);
172
173 if(Parameter[0]!='('){
174 SetError(10,"Circle",NowLine);
175 return;
176 }
177 for(i=1,i2=0,PareNum=1;;i++,i2++){
178 if(Parameter[i]=='(') PareNum++;
179 if(Parameter[i]==')'){
180 PareNum--;
181 if(PareNum==0){
182 buffer[i2]=0;
183 break;
184 }
185 }
186 buffer[i2]=Parameter[i];
187 }
188
189 i++;
190 if(Parameter[i]!=','){
191 SetError(10,"Circle",NowLine);
192 return;
193 }
194 i++;
195
196 i=GetOneParameter(Parameter,i,temporary); //第3パラメータ取得(radius)
197 lstrcat(buffer,",");
198 lstrcat(buffer,temporary);
199 if(Parameter[i]=='\0'){
200 lstrcat(buffer,",7,0,0,1");
201 return;
202 }
203
204 i=GetOneParameter(Parameter,i,temporary); //第4パラメータ取得(color)
205 if(temporary[0]=='\0') lstrcpy(temporary,"7");
206 lstrcat(buffer,",");
207 lstrcat(buffer,temporary);
208 lstrcpy(temp2,temporary);
209 if(Parameter[i]=='\0'){
210 lstrcat(buffer,",0,0,1");
211 return;
212 }
213
214 i=GetOneParameter(Parameter,i,temporary); //第5パラメータ取得(start)
215 lstrcat(buffer,",");
216 lstrcat(buffer,temporary);
217 if(Parameter[i]=='\0'){
218 lstrcat(buffer,",0,1");
219 return;
220 }
221
222 i=GetOneParameter(Parameter,i,temporary); //第6パラメータ取得(end)
223 lstrcat(buffer,",");
224 lstrcat(buffer,temporary);
225 if(Parameter[i]=='\0'){
226 lstrcat(buffer,",1");
227 return;
228 }
229
230 i=GetOneParameter(Parameter,i,temporary); //第7パラメータ取得(aspect)
231 lstrcat(buffer,",");
232 if(temporary[0]=='\0')
233 lstrcat(buffer,"1");
234 else
235 lstrcat(buffer,temporary);
236 if(Parameter[i]=='\0') return;
237
238 i=GetOneParameter(Parameter,i,temporary); //第8パラメータ取得(f)
239 if(lstrcmpi(temporary,"f")==0){
240 lstrcat(buffer,",1");
241 }
242 else{
243 SetError(10,"Circle",NowLine);
244 return;
245 }
246
247 if(Parameter[i]){
248 i=GetOneParameter(Parameter,i,temporary); //第9パラメータ取得(BrushColor)
249 if(temporary[0]=='\0') lstrcpy(temporary,"7");
250 lstrcat(buffer,",");
251 lstrcat(buffer,temporary);
252 if(Parameter[i-1]==','){
253 SetError(10,"Circle",NowLine);
254 return;
255 }
256 }
257 else{
258 lstrcat(buffer,",");
259 lstrcat(buffer,temp2);
260 }
261}
262void ComPSet(char *Parameter,char *buffer,int NowLine){
263 int i,i2,PareNum;
264
265 KillStringSpaces(Parameter);
266
267 if(Parameter[0]!='('){
268 SetError(10,"PSet",NowLine);
269 return;
270 }
271 for(i=1,i2=0,PareNum=1;;i++,i2++){
272 if(Parameter[i]=='(') PareNum++;
273 if(Parameter[i]==')'){
274 PareNum--;
275 if(PareNum==0){
276 buffer[i2]=0;
277 break;
278 }
279 }
280 buffer[i2]=Parameter[i];
281 }
282
283 if(Parameter[i+1]==',')lstrcat(buffer,Parameter+i+1);
284 else if(Parameter[i+1]=='\0') lstrcat(buffer,",7");
285 else{
286 SetError(10,"PSet",NowLine);
287 return;
288 }
289}
290void ComPaint(char *Parameter,char *buffer,int NowLine){
291 int i,i2,PareNum;
292
293 KillStringSpaces(Parameter);
294
295 if(Parameter[0]!='('){
296 SetError(10,"Paint",NowLine);
297 return;
298 }
299 for(i=1,i2=0,PareNum=1;;i++,i2++){
300 if(Parameter[i]=='(') PareNum++;
301 if(Parameter[i]==')'){
302 PareNum--;
303 if(PareNum==0){
304 buffer[i2]=0;
305 break;
306 }
307 }
308 buffer[i2]=Parameter[i];
309 }
310 if(Parameter[i+1]!=','){
311 SetError(10,"Paint",NowLine);
312 return;
313 }
314
315 lstrcat(buffer,Parameter+i+1);
316}
Note: See TracBrowser for help on using the repository browser.