void showSubst (Term t) { #ifdef DEBUG if (!DEBUGL (5)) return; indent (); eprintf ("Substituting "); termPrint (t); eprintf (", typed "); termlistPrint (t->stype); if (realTermLeaf (t->subst)) { eprintf ("->"); termlistPrint (t->subst->stype); } else { eprintf (", composite term"); } if (t->type != VARIABLE) { eprintf (" (bound roleconstant)"); } eprintf ("\n"); #endif }
//! Determine whether this is a leaf construct with a ticket in it int isTicketTerm (Term t) { if (t != NULL) { if (realTermLeaf (t)) { if (inTermlist (t->stype, TERM_Ticket)) { return true; } else { if (realTermVariable (t)) { return isTicketTerm (t->subst); } } } } return false; }
//! Print a term in XML form (iteration inner) void xmlTermPrintInner (Term term) { if (term != NULL) { if (!show_substitution_path) { /* In a normal situation, variables are immediately substituted, and * only the result is output. */ term = deVar (term); } if (realTermLeaf (term)) { // Variable? if (realTermVariable (term)) { Term substbuffer; eprintf ("<var name=\""); if (term->subst == NULL) { // Free variable termPrint (term); // Must be a normal termPrint eprintf ("\" free=\"true\" />"); } else { // Bound variable substbuffer = term->subst; // Temporarily unsubst for printing term->subst = NULL; termPrint (term); // Must be a normal termPrint term->subst = substbuffer; eprintf ("\">"); xmlTermPrintInner (term->subst); eprintf ("</var>"); } } else { // Constant eprintf ("<const>"); termPrint (term); // Must be a normal termPrint eprintf ("</const>"); } } else { // Node if (realTermEncrypt (term)) { if (isTermLeaf (TermKey (term)) && inTermlist (TermKey (term)->stype, TERM_Function)) { /* function application */ eprintf ("<apply><function>"); xmlTermPrintInner (TermKey (term)); eprintf ("</function><arg>"); xmlTermPrintInner (TermOp (term)); eprintf ("</arg></apply>"); } else { eprintf ("<encrypt><op>"); xmlTermPrintInner (TermOp (term)); eprintf ("</op><key>"); xmlTermPrintInner (TermKey (term)); eprintf ("</key></encrypt>"); } } else { // Assume tuple eprintf ("<tuple><op1>"); xmlTermPrintInner (TermOp1 (term)); eprintf ("</op1><op2>"); xmlTermPrintInner (TermOp2 (term)); eprintf ("</op2></tuple>"); } } } }