Exemplo n.º 1
0
ATerm SSL_getPlaceholder(ATerm t) {
    int type = ATgetType(t);
    if(type != AT_PLACEHOLDER) {
      ATfprintf(stderr, "[error] SSL_getPlaceholder: not a placeholder: %t \n", t);
      _fail(t);
    } else {
	ATermPlaceholder ph = (ATermPlaceholder) t;
	ATerm result = ATgetPlaceholder(ph);
	return result;
    }
}
Exemplo n.º 2
0
static void term2buf(ATerm t)
{
    ATerm annos = AT_getAnnotations(t);
    if(annos != NULL) {
        char2buf('{');
    }

    switch(ATgetType(t)) {
    case AT_INT:
        wprintf("%d", ATgetInt((ATermInt)t));
        break;
    case AT_REAL:
        wprintf("%f", ATgetReal((ATermReal)t));
        break;
    case AT_APPL:
    {
        int cur_arg, arity;
        ATermAppl appl = (ATermAppl)t;
        AFun sym = ATgetSymbol(appl);

        if(ATisQuoted(sym))
            qstr2buf(ATgetName(sym));
        else
            str2buf(ATgetName(sym));

        arity = ATgetArity(sym);
        if(arity > 0) {
            char2buf('(');

            for(cur_arg=0; cur_arg<arity; cur_arg++) {
                term2buf(ATgetArgument(appl, cur_arg));
                if(cur_arg < (arity-1))
                    char2buf(',');
            }
            char2buf(')');
        }
    }
    break;
    case AT_LIST:
    {
        ATermList l = (ATermList)t;
        char2buf('{');
        while(!ATisEmpty(l)) {
            ATerm el = ATgetFirst(l);
            l = ATgetNext(l);
            term2buf(el);
            if(!ATisEmpty(l))
                char2buf(' ');
        }
        char2buf('}');
    }
    break;

    case AT_PLACEHOLDER:
    {
        char2buf('<');
        term2buf(ATgetPlaceholder((ATermPlaceholder)t));
        char2buf('>');
    }
    break;

    case AT_BLOB:
        ATerror("blobs are not supported by tcltk-adapter!\n");

    default:
        ATabort("illegal term type!\n");
    }

    if(annos != NULL) {
        char2buf(' ');
        term2buf(annos);
        char2buf('}');
    }
}