org.quasiliteral.term
Class Term

java.lang.Object
  |
  +--org.quasiliteral.term.Term
All Implemented Interfaces:
Astro, AstroArg, DeepPassByCopy, Marker, PassByConstruction, Persistent, Selfless, Serializable

public final class Term
extends Object
implements Persistent, DeepPassByCopy, Astro

Untamed:

See Also:
Serialized Form

Field Summary
private  ConstList myArgs
          A term is a functor (the above three instance variables) as parameterized by a list of argument Terms.
private  int myHeight
          Just used to decide how to pretty print.
private  Object myOptData
           
private  SourceSpan myOptSpan
           
private  AstroTag myTag
           
private static StaticMaker OptTermMaker
          Initialized lazily to avoid a circularity.
(package private) static long serialVersionUID
           
 
Fields inherited from interface org.erights.e.elib.serial.Persistent
HONORARY, HONORED_NAMES
 
Fields inherited from interface org.erights.e.elib.serial.DeepPassByCopy
HONORARY, HONORED_NAMES
 
Constructor Summary
(package private) Term(AstroTag tag, Object optData, SourceSpan optSpan, ConstList args)
          Makes a Term that represents a node in an abstract syntax tree, ie, a Term tree.
 
Method Summary
 void __printOn(TextWriter out)
          Enabled:
 String asText()
          Enabled:
 Astro build(AstroBuilder builder)
          Enabled:
 double compareTo(Term other)
          Enabled: Lexicographic comparison of, in order: the tags the data the args
 ConstList getArgs()
          Enabled: A term is a functor (the above three instance variables) as parameterized by a list of argument Terms.
 int getHeight()
          Enabled: What's the longest distance to the bottom?
 Object getOptArgData()
          Enabled:
 Object getOptArgData(short tagCode)
          Enabled:
 String getOptArgString(short tagCode)
          Enabled:
 Object getOptData()
          Enabled: Either literal data or null.
 SourceSpan getOptSpan()
          Enabled: What source text was originally lexed or parsed to produce this token?
 String getOptString()
          Enabled:
 short getOptTagCode()
          Enabled:
 Object[] getSpreadUncall()
          Enabled: Uses 'TermMaker(myTag, myOptData, myOptSpan, myArgs)'
 AstroTag getTag()
          Enabled: Represents the token-type of the functor of this term.
 void prettyPrintOn(TextWriter out, boolean quasiFlag, boolean bagFlag)
          Enabled:
 String toString()
          Suppressed:
 Astro withArgs(ConstList args)
          Enabled:
 Astro withoutArgs()
          Enabled:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID

OptTermMaker

private static StaticMaker OptTermMaker
Initialized lazily to avoid a circularity.


myTag

private final AstroTag myTag

myOptData

private final Object myOptData

myOptSpan

private final SourceSpan myOptSpan

myArgs

private final ConstList myArgs
A term is a functor (the above three instance variables) as parameterized by a list of argument Terms. These are the arguments. A term of zero arguments is often refered to as a "functor", so there's no information beyond the functor-part.


myHeight

private transient int myHeight
Just used to decide how to pretty print.

Initialized lazily. 0 if uninitialized, so does not need to be recalculated on revival.

Constructor Detail

Term

Term(AstroTag tag,
     Object optData,
     SourceSpan optSpan,
     ConstList args)
Makes a Term that represents a node in an abstract syntax tree, ie, a Term tree.

The invariants of a Term are not checked here, but rather are enforced by the callers in this class and in TermBuilder.

Parameters:
tag - Identifies a token type in a particular grammar or set of related grammars, used as the functor (or "label") of this Term
optData - Either Character, BigInteger, Double, or Twine or null. If not null, then the tag must represent the canonical literal type for this kind of data in this schema.
optSpan - Where was the source text this token was extracted from?
args - This Term's argument list -- a list of Terms
Method Detail

getSpreadUncall

public Object[] getSpreadUncall()
Enabled: Uses 'TermMaker(myTag, myOptData, myOptSpan, myArgs)'

Specified by:
getSpreadUncall in interface Selfless

build

public Astro build(AstroBuilder builder)
Enabled:

Specified by:
build in interface Astro

getTag

public AstroTag getTag()
Enabled: Represents the token-type of the functor of this term.

Specified by:
getTag in interface Astro

getOptTagCode

public short getOptTagCode()
Enabled:

Specified by:
getOptTagCode in interface Astro

getOptData

public Object getOptData()
Enabled: Either literal data or null. If not null, then the tag must represent the canonical literal type for this kind of data in this schema.

Specified by:
getOptData in interface Astro

getOptString

public String getOptString()
Enabled:

Specified by:
getOptString in interface Astro

getOptArgData

public Object getOptArgData()
Enabled:

Specified by:
getOptArgData in interface Astro

getOptArgData

public Object getOptArgData(short tagCode)
Enabled:

Specified by:
getOptArgData in interface Astro

getOptArgString

public String getOptArgString(short tagCode)
Enabled:

Specified by:
getOptArgString in interface Astro

getOptSpan

public SourceSpan getOptSpan()
Enabled: What source text was originally lexed or parsed to produce this token?

Specified by:
getOptSpan in interface AstroArg

getArgs

public ConstList getArgs()
Enabled: A term is a functor (the above three instance variables) as parameterized by a list of argument Terms. These are the arguments. A term of zero arguments is often refered to as a "functor", so there's no information beyond the functor-part.

Specified by:
getArgs in interface Astro

withoutArgs

public Astro withoutArgs()
Enabled:

Specified by:
withoutArgs in interface Astro

withArgs

public Astro withArgs(ConstList args)
Enabled:

Specified by:
withArgs in interface Astro

compareTo

public double compareTo(Term other)
Enabled: Lexicographic comparison of, in order:


getHeight

public int getHeight()
Enabled: What's the longest distance to the bottom?

A leaf node is height 1. All other nodes are one more than the height of their highest child. This is used for pretty printing.


__printOn

public void __printOn(TextWriter out)
               throws IOException
Enabled:

IOException

toString

public String toString()
Suppressed:

Overrides:
toString in class Object
Returns:
a string representation of the object.

asText

public String asText()
Enabled:


prettyPrintOn

public void prettyPrintOn(TextWriter out,
                          boolean quasiFlag,
                          boolean bagFlag)
                   throws IOException
Enabled:

IOException


comments?