VALUE* eval_string(char *prog_str, NODE *static_scope, NODE *macro_map) { NODE *prog = parseForms(prog_str); debugVal(prog,"before macroexpand: "); prog = (NODE*)macroexpand(prog,static_scope,macro_map); debugVal(prog,"after macroexpand: "); VALUE *val = evaluate((VALUE*)prog,static_scope); decRef(prog); return val; }
T_SYMBOL intern(char *c_str) { if (!sym_map) parser_init(); c_str = strdup(c_str); for (int i = 0; c_str[i]; i++) c_str[i] = toupper(c_str[i]); debug("intern: %s %u\n",c_str,hash(c_str)); SYMBOL *sym = newSYMBOL(hash(c_str)); STRING *str = newSTRING(c_str); NODE *entry; while ((entry = binmap_find(sym,sym_map))) { debugVal(entry,"matching: "); if (cmpSTRING((STRING*)entry->addr,str)) { decRef(entry); sym->sym++; } else { break; } } if (!entry) { debug("adding symbol: %s\n",c_str); binmap_put(sym,str,sym_map); return sym->sym; } else { decRef(sym); decRef(str); decRef(entry); return ((SYMBOL*)entry->data)->sym; } }
app_report() /* Application-dependent report, called by report() */ { unsigned *c = bestfit.chrom; int valeur[NB_COMPARAISONS]; chrom2val(c,valeur); debugVal(valeur); }
// Lorsqu'on termine l'application void app_exit(int sig){ unsigned *c = bestfit.chrom; int valeur[NB_COMPARAISONS]; chrom2val(c,valeur); double tri = fitnessTri(valeur); printf("=== MEILLEUR RESULTAT ===\n"); printf("Fitness total : %f\n",bestfit.fitness); printf("Fitness du tri: %f\n",tri); writechrom(bestfit.chrom); debugVal(valeur); debugCmp(valeur); exit(0); }
void SonmicroRfid::debugVal(long val, bool newline) const { debugVal(val, newline, DEC); }
NODE* parse(char **exp) { if (!sym_map) parser_init(); debug("Parse List: %s\n",*exp); NODE *head = NIL; while (**exp) { switch (*((*exp)++)) { case '\'': { debug("to quote: %s\n",*exp); NODE *quoted = parse(exp); debugVal(quoted->data,"quoted: "); list_push(newNODE(newPRIMFUNC(SPEC_QUOTE,l_quote),newNODE(quoted->data,NIL)),&head); if (quoted->addr) head = list_join(list_reverse((NODE*)quoted->addr),head); head = list_reverse(head); debugVal(head,"expression: "); return head; } case '(': list_push(parse(exp),&head); break; case ')': head = list_reverse(head); debugVal(head,"expression: "); return head; case ';': while (**exp != '\0' && **exp != '\r' && **exp != '\n') (*exp)++; break; case '\n': case '\r': case '\t': case ' ': break; default: { char *sym = *exp-1; debug("origin: %s\n",sym); while (**exp && **exp != ' ' && **exp != ')' && **exp != '\n' && **exp != '\r' && **exp != '\t') (*exp)++; char old = **exp; **exp = 0; debug("literal: %s\n",sym); switch (sym[0]) { case '+': case '-': if (!isdigit(sym[1])) { list_push(newSYMBOL(intern(sym)),&head); break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { bool real = false; char *scn = sym+1; while (*scn) { if (*scn == '.') { real = true; } else if (!isdigit(*scn)) { error("Malformed number character %c",*scn); } scn++; } if (real) { list_push(newREAL(atof(sym)),&head); } else { list_push(newINTEGER(atoi(sym)),&head); } } break; default: list_push(newSYMBOL(intern(sym)),&head); break; } **exp = old; if (head->data->type == ID_SYMBOL) { NODE *literal; if ((literal = binmap_find(head->data,literal_map))) { NODE *last = (NODE*)head->addr; incRef(last); decRef(head); incRef(literal->addr); head = last; list_push(literal->addr,&head); decRef(literal); } } debugVal(head,"parsed: "); } } } head = list_reverse(head); debugVal(head,"dangling: "); return head; }