comparison lwlib/lw_expr.c @ 370:6b33faa21a0a

Debugging output and bugfixing pass 0
author lost@starbug
date Tue, 20 Apr 2010 21:59:58 -0600
parents 34dfc9747f23
children 9c24d9d485b9
comparison
equal deleted inserted replaced
369:898a41f7eb59 370:6b33faa21a0a
190 r = lw_expr_build_aux(exprtype, args); 190 r = lw_expr_build_aux(exprtype, args);
191 va_end(args); 191 va_end(args);
192 return r; 192 return r;
193 } 193 }
194 194
195 void lw_expr_print(lw_expr_t E) 195 void lw_expr_print(lw_expr_t E, FILE *fp)
196 { 196 {
197 struct lw_expr_opers *o; 197 struct lw_expr_opers *o;
198 int c = 0; 198 int c = 0;
199 199
200 for (o = E -> operands; o; o = o -> next) 200 for (o = E -> operands; o; o = o -> next)
201 { 201 {
202 c++; 202 c++;
203 lw_expr_print(o -> p); 203 lw_expr_print(o -> p, fp);
204 } 204 }
205 205
206 switch (E -> type) 206 switch (E -> type)
207 { 207 {
208 case lw_expr_type_int: 208 case lw_expr_type_int:
209 printf("%d ", E -> value); 209 fprintf(fp, "%d ", E -> value);
210 break; 210 break;
211 211
212 case lw_expr_type_var: 212 case lw_expr_type_var:
213 printf("V(%s) ", (char *)(E -> value2)); 213 fprintf(fp, "V(%s) ", (char *)(E -> value2));
214 break; 214 break;
215 215
216 case lw_expr_type_special: 216 case lw_expr_type_special:
217 printf("S(%d,%p) ", E -> value, E -> value2); 217 fprintf(fp, "S(%d,%p) ", E -> value, E -> value2);
218 break; 218 break;
219 219
220 case lw_expr_type_oper: 220 case lw_expr_type_oper:
221 printf("[%d]", c); 221 fprintf(fp, "[%d]", c);
222 switch (E -> value) 222 switch (E -> value)
223 { 223 {
224 case lw_expr_oper_plus: 224 case lw_expr_oper_plus:
225 printf("+ "); 225 fprintf(fp, "+ ");
226 break; 226 break;
227 227
228 case lw_expr_oper_minus: 228 case lw_expr_oper_minus:
229 printf("- "); 229 fprintf(fp, "- ");
230 break; 230 break;
231 231
232 case lw_expr_oper_times: 232 case lw_expr_oper_times:
233 printf("* "); 233 fprintf(fp, "* ");
234 break; 234 break;
235 235
236 case lw_expr_oper_divide: 236 case lw_expr_oper_divide:
237 printf("/ "); 237 fprintf(fp, "/ ");
238 break; 238 break;
239 239
240 case lw_expr_oper_mod: 240 case lw_expr_oper_mod:
241 printf("%% "); 241 fprintf(fp, "%% ");
242 break; 242 break;
243 243
244 case lw_expr_oper_intdiv: 244 case lw_expr_oper_intdiv:
245 printf("\\ "); 245 fprintf(fp, "\\ ");
246 break; 246 break;
247 247
248 case lw_expr_oper_bwand: 248 case lw_expr_oper_bwand:
249 printf("BWAND "); 249 fprintf(fp, "BWAND ");
250 break; 250 break;
251 251
252 case lw_expr_oper_bwor: 252 case lw_expr_oper_bwor:
253 printf("BWOR "); 253 fprintf(fp, "BWOR ");
254 break; 254 break;
255 255
256 case lw_expr_oper_bwxor: 256 case lw_expr_oper_bwxor:
257 printf("BWXOR "); 257 fprintf(fp, "BWXOR ");
258 break; 258 break;
259 259
260 case lw_expr_oper_and: 260 case lw_expr_oper_and:
261 printf("AND "); 261 fprintf(fp, "AND ");
262 break; 262 break;
263 263
264 case lw_expr_oper_or: 264 case lw_expr_oper_or:
265 printf("OR "); 265 fprintf(fp, "OR ");
266 break; 266 break;
267 267
268 case lw_expr_oper_neg: 268 case lw_expr_oper_neg:
269 printf("NEG "); 269 fprintf(fp, "NEG ");
270 break; 270 break;
271 271
272 case lw_expr_oper_com: 272 case lw_expr_oper_com:
273 printf("COM "); 273 fprintf(fp, "COM ");
274 break; 274 break;
275 275
276 default: 276 default:
277 printf("OPER "); 277 fprintf(fp, "OPER ");
278 break; 278 break;
279 } 279 }
280 break; 280 break;
281 default: 281 default:
282 printf("ERR "); 282 fprintf(fp, "ERR ");
283 break; 283 break;
284 } 284 }
285 } 285 }
286 286
287 /* 287 /*
781 int opern, i; 781 int opern, i;
782 lw_expr_t term1, term2, term3; 782 lw_expr_t term1, term2, term3;
783 783
784 if (!**p || isspace(**p) || **p == ')' || **p == ',' || **p == ']') 784 if (!**p || isspace(**p) || **p == ')' || **p == ',' || **p == ']')
785 return NULL; 785 return NULL;
786 786
787 term1 = lw_expr_parse_term(p, priv); 787 term1 = lw_expr_parse_term(p, priv);
788 if (!term1) 788 if (!term1)
789 return NULL; 789 return NULL;
790 790
791 eval_next: 791 eval_next: