ua.gradsoft.termware
Class TermHelper

java.lang.Object
  extended by ua.gradsoft.termware.TermHelper

public class TermHelper
extends Object

Helper class for terms operations


Constructor Summary
TermHelper()
           
 
Method Summary
static Term attributeTree(Term tree, String attrName, Term attribute, TermCondition condition)
          attribute tree: i.e.
static int compareNameIndexes(Object x, Object y)
           
static Term copyAttributes(Term dst, Term src)
          copy attributes from src term to dst term
static Term escapeX(Term t)
          change $x entites to _x(minFv($x)).
static Term getAttribute(Term t, String name)
          get attribute name of term t
static boolean isAttributed(Term t)
          return true, if term is attributed.
static Term reverseList(TermWareInstance instance, Term t)
          reverse list
static Term setAttribute(Term t, String name, int attribute)
          set int attribute
static Term setAttribute(Term t, String name, String attribute)
          set string attribute
static Term setAttribute(Term t, String name, Term attribute)
          set attribute to term.
static Term stringToName(String name)
          transform string in form (x/y/z) to form _name(x,y,z);
static String termToPrettyString(Term t)
           
static String termToPrettyString(Term t, String languageName, Term printerArgs)
          pretty print t
static String termToString(Term t)
          print into string.
static Term unescapeX(Term t)
          change _x(i) entites to $i
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TermHelper

public TermHelper()
Method Detail

termToString

public static String termToString(Term t)
print into string.

Returns:
string representation of t

termToPrettyString

public static String termToPrettyString(Term t,
                                        String languageName,
                                        Term printerArgs)
                                 throws TermWareException
pretty print t

Throws:
TermWareException

termToPrettyString

public static String termToPrettyString(Term t)
                                 throws TermWareException
Throws:
TermWareException

compareNameIndexes

public static int compareNameIndexes(Object x,
                                     Object y)

setAttribute

public static Term setAttribute(Term t,
                                String name,
                                Term attribute)
set attribute to term. If t is not attributed - attribute one. (i. e. create instance of AttributedTerm which wrap original term).

Returns:
attributed term.

setAttribute

public static Term setAttribute(Term t,
                                String name,
                                String attribute)
set string attribute

See Also:
setAttribute(ua.gradsoft.termware.Term, java.lang.String, ua.gradsoft.termware.Term)

setAttribute

public static Term setAttribute(Term t,
                                String name,
                                int attribute)
set int attribute

See Also:
setAttribute(ua.gradsoft.termware.Term, java.lang.String, ua.gradsoft.termware.Term)

getAttribute

public static Term getAttribute(Term t,
                                String name)
get attribute name of term t

Parameters:
t - term
name - name of attribute to get.
Returns:
attribute name of term t or NIL, if attribute is not set or term is not attributed.
See Also:
AttributedTerm

copyAttributes

public static Term copyAttributes(Term dst,
                                  Term src)
copy attributes from src term to dst term


isAttributed

public static boolean isAttributed(Term t)
return true, if term is attributed. (i. e. setAttribute(t,x,u)==t. )


attributeTree

public static Term attributeTree(Term tree,
                                 String attrName,
                                 Term attribute,
                                 TermCondition condition)
                          throws TermWareException
attribute tree: i.e. set attribute to each subterm, which satisficy condition.

Throws:
TermWareException

escapeX

public static Term escapeX(Term t)
                    throws TermWareException
change $x entites to _x(minFv($x)).

Parameters:
t - - term to change. (can be changed during processing).
Returns:
substituted term.
Throws:
TermWareException

unescapeX

public static Term unescapeX(Term t)
                      throws TermWareException
change _x(i) entites to $i

Parameters:
t - - term to change. (can be changed during processing).
Returns:
substituted term.
Throws:
TermWareException

stringToName

public static Term stringToName(String name)
                         throws TermWareException
transform string in form (x/y/z) to form _name(x,y,z);

Throws:
TermWareException

reverseList

public static Term reverseList(TermWareInstance instance,
                               Term t)
                        throws TermWareException
reverse list

Throws:
TermWareException