2003-11-16 17:46:31 +00:00
|
|
|
#include "aterm.hh"
|
|
|
|
|
|
|
|
|
|
|
|
string atPrint(ATerm t)
|
|
|
|
{
|
|
|
|
if (!t) throw Error("attempt to print null aterm");
|
|
|
|
char * s = ATwriteToString(t);
|
|
|
|
if (!s) throw Error("cannot print term");
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ostream & operator << (ostream & stream, ATerm e)
|
|
|
|
{
|
|
|
|
return stream << atPrint(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-18 11:22:29 +00:00
|
|
|
Error badTerm(const format & f, ATerm t)
|
|
|
|
{
|
|
|
|
char * s = ATwriteToString(t);
|
|
|
|
if (!s) throw Error("cannot print term");
|
|
|
|
if (strlen(s) > 1000) {
|
|
|
|
int len;
|
|
|
|
s = ATwriteToSharedString(t, &len);
|
|
|
|
if (!s) throw Error("cannot print term");
|
|
|
|
}
|
|
|
|
return Error(format("%1%, in `%2%'") % f.str() % (string) s);
|
|
|
|
}
|