- Modified brace printing behaviour.
This commit is contained in:
parent
0590accb86
commit
1868a2b6fa
42
src/latex.c
42
src/latex.c
@ -91,7 +91,7 @@ latexDone (const System sys)
|
|||||||
//! Print a term using LaTeX and highlighting.
|
//! Print a term using LaTeX and highlighting.
|
||||||
/**
|
/**
|
||||||
* Basically a recode of termPrint, now specific using latex codes and with a
|
* Basically a recode of termPrint, now specific using latex codes and with a
|
||||||
* highlighting feature.
|
* highlighting feature. There is still some obsolete code to show variable mappings in a term.
|
||||||
*@param term a term to be printed.
|
*@param term a term to be printed.
|
||||||
*@param highlight a list of terms to be highlighted.
|
*@param highlight a list of terms to be highlighted.
|
||||||
*/
|
*/
|
||||||
@ -134,15 +134,7 @@ latexTermPrint (Term term, Termlist highlight)
|
|||||||
if (realTermTuple (term))
|
if (realTermTuple (term))
|
||||||
{
|
{
|
||||||
printf ("(");
|
printf ("(");
|
||||||
while (realTermTuple (term))
|
latexTermTuplePrint (term);
|
||||||
{
|
|
||||||
latexTermPrint (term->op1, highlight);
|
|
||||||
printf (",");
|
|
||||||
term = term->op2;
|
|
||||||
if (!realTermTuple (term))
|
|
||||||
latexTermPrint (term, highlight);
|
|
||||||
|
|
||||||
}
|
|
||||||
printf (")");
|
printf (")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -154,14 +146,14 @@ latexTermPrint (Term term, Termlist highlight)
|
|||||||
/* function application */
|
/* function application */
|
||||||
latexTermPrint (term->key, highlight);
|
latexTermPrint (term->key, highlight);
|
||||||
printf ("(");
|
printf ("(");
|
||||||
latexTermPrint (term->op, highlight);
|
latexTermTuplePrint (term->op, highlight);
|
||||||
printf (")");
|
printf (")");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* normal encryption */
|
/* normal encryption */
|
||||||
printf ("\\{");
|
printf ("\\{");
|
||||||
latexTermPrint (term->op, highlight);
|
latexTermTuplePrint (term->op, highlight);
|
||||||
printf ("\\}_{");
|
printf ("\\}_{");
|
||||||
latexTermPrint (term->key, highlight);
|
latexTermPrint (term->key, highlight);
|
||||||
printf ("}");
|
printf ("}");
|
||||||
@ -169,6 +161,32 @@ latexTermPrint (Term term, Termlist highlight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Print an inner (tuple) term using LaTeX, without brackets.
|
||||||
|
/**
|
||||||
|
* The tuple printing only works correctly for normalized terms.
|
||||||
|
* If not, they might are displayed as "((x,y),z)". Maybe that is even
|
||||||
|
* desirable to distinguish them.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
latexTermTuplePrint (Term term, Termlist hl)
|
||||||
|
{
|
||||||
|
if (term == NULL)
|
||||||
|
{
|
||||||
|
printf ("Empty term");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
term = deVar(term);
|
||||||
|
while (realTermTuple (term))
|
||||||
|
{
|
||||||
|
// To remove any brackets, change this into latexTermTuplePrint.
|
||||||
|
latexTermPrint (term->op1, hl);
|
||||||
|
printf (",");
|
||||||
|
term = deVar(term->op2);
|
||||||
|
}
|
||||||
|
latexTermPrint(term, hl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//! Print a termlist in LaTeX using highlighting.
|
//! Print a termlist in LaTeX using highlighting.
|
||||||
/**
|
/**
|
||||||
* Extending LaTeX term printing to term list printing, again with highlight
|
* Extending LaTeX term printing to term list printing, again with highlight
|
||||||
|
@ -17,5 +17,7 @@ void latexMessagePrint(const System sys, int from, int to);
|
|||||||
void latexLearnComment(const System sys, Termlist tl);
|
void latexLearnComment(const System sys, Termlist tl);
|
||||||
void latexTracePrint(System sys);
|
void latexTracePrint(System sys);
|
||||||
void attackDisplayLatex(System sys);
|
void attackDisplayLatex(System sys);
|
||||||
|
void latexTermPrint (Term term, Termlist hl);
|
||||||
|
void latexTermTuplePrint (Term term, Termlist hl);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
47
src/terms.c
47
src/terms.c
@ -231,6 +231,12 @@ termOccurs (Term t, Term tsub)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Print a term to stdout.
|
//! Print a term to stdout.
|
||||||
|
/**
|
||||||
|
* The tuple printing only works correctly for normalized terms.
|
||||||
|
* If not, they might are displayed as "((x,y),z)". Maybe that is even
|
||||||
|
* desirable to distinguish them.
|
||||||
|
*\sa termTuplePrint()
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
termPrint (Term term)
|
termPrint (Term term)
|
||||||
{
|
{
|
||||||
@ -271,15 +277,7 @@ termPrint (Term term)
|
|||||||
if (realTermTuple (term))
|
if (realTermTuple (term))
|
||||||
{
|
{
|
||||||
printf ("(");
|
printf ("(");
|
||||||
while (realTermTuple (term))
|
termTuplePrint(term);
|
||||||
{
|
|
||||||
termPrint (term->op1);
|
|
||||||
printf (",");
|
|
||||||
term = term->op2;
|
|
||||||
if (!realTermTuple (term))
|
|
||||||
termPrint (term);
|
|
||||||
|
|
||||||
}
|
|
||||||
printf (")");
|
printf (")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -291,7 +289,7 @@ termPrint (Term term)
|
|||||||
/* function application */
|
/* function application */
|
||||||
termPrint (term->key);
|
termPrint (term->key);
|
||||||
printf ("(");
|
printf ("(");
|
||||||
termPrint (term->op);
|
termTuplePrint (term->op);
|
||||||
printf (")");
|
printf (")");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -300,7 +298,7 @@ termPrint (Term term)
|
|||||||
if (globalLatex)
|
if (globalLatex)
|
||||||
{
|
{
|
||||||
printf ("\\{");
|
printf ("\\{");
|
||||||
termPrint (term->op);
|
termTuplePrint (term->op);
|
||||||
printf ("\\}_{");
|
printf ("\\}_{");
|
||||||
termPrint (term->key);
|
termPrint (term->key);
|
||||||
printf ("}");
|
printf ("}");
|
||||||
@ -308,7 +306,7 @@ termPrint (Term term)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf ("{");
|
printf ("{");
|
||||||
termPrint (term->op);
|
termTuplePrint (term->op);
|
||||||
printf ("}");
|
printf ("}");
|
||||||
termPrint (term->key);
|
termPrint (term->key);
|
||||||
}
|
}
|
||||||
@ -316,6 +314,31 @@ termPrint (Term term)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Print an inner (tuple) term to stdout, without brackets.
|
||||||
|
/**
|
||||||
|
* The tuple printing only works correctly for normalized terms.
|
||||||
|
* If not, they might are displayed as "((x,y),z)". Maybe that is even
|
||||||
|
* desirable to distinguish them.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
termTuplePrint (Term term)
|
||||||
|
{
|
||||||
|
if (term == NULL)
|
||||||
|
{
|
||||||
|
printf ("Empty term");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
term = deVar(term);
|
||||||
|
while (realTermTuple (term))
|
||||||
|
{
|
||||||
|
// To remove any brackets, change this into termTuplePrint.
|
||||||
|
termPrint (term->op1);
|
||||||
|
printf (",");
|
||||||
|
term = deVar(term->op2);
|
||||||
|
}
|
||||||
|
termPrint(term);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//! Make a deep copy of a term.
|
//! Make a deep copy of a term.
|
||||||
/**
|
/**
|
||||||
|
@ -101,6 +101,7 @@ int hasTermVariable (Term term);
|
|||||||
int isTermEqualFn (Term term1, Term term2);
|
int isTermEqualFn (Term term1, Term term2);
|
||||||
int termOccurs (Term t, Term tsub);
|
int termOccurs (Term t, Term tsub);
|
||||||
void termPrint (Term term);
|
void termPrint (Term term);
|
||||||
|
void termTuplePrint (Term term);
|
||||||
Term termDuplicate (const Term term);
|
Term termDuplicate (const Term term);
|
||||||
Term termDuplicateDeep (const Term term);
|
Term termDuplicateDeep (const Term term);
|
||||||
Term termDuplicateUV (Term term);
|
Term termDuplicateUV (Term term);
|
||||||
|
Loading…
Reference in New Issue
Block a user