source: dev/trunk/abdev/BasicCompiler_Common/CommandFormat.cpp@ 389

Last change on this file since 389 was 206, checked in by dai_9181, 17 years ago

コード全体のリファクタリングを実施

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