org.quasiliteral.quasiterm
Class QAstroArg

java.lang.Object
  |
  +--org.quasiliteral.quasiterm.QAstroArg
All Implemented Interfaces:
AstroArg, Marker, PassByConstruction, Persistent, Selfless, Serializable
Direct Known Subclasses:
QAstro, QSome

public abstract class QAstroArg
extends Object
implements Selfless, PassByConstruction, Persistent, AstroArg

Untamed:

Author:
Mark S. Miller
See Also:
Serialized Form

Field Summary
(package private) static ValueGuard EListGuard
           
(package private) static int[] EMPTY_INDEX
           
(package private)  AstroBuilder myBuilder
           
(package private)  SourceSpan myOptSpan
           
(package private) static long serialVersionUID
           
 
Fields inherited from interface org.erights.e.elib.tables.Selfless
HONORARY, HONORED_NAMES
 
Fields inherited from interface org.erights.e.elib.serial.PassByConstruction
HONORARY, HONORED_NAMES
 
Fields inherited from interface org.erights.e.elib.serial.Persistent
HONORARY, HONORED_NAMES
 
Constructor Summary
QAstroArg(AstroBuilder builder, SourceSpan optSpan)
          Enabled:
 
Method Summary
 void __printOn(TextWriter out)
          Enabled:
 String asText()
          Enabled:
(package private) abstract  void endShape(FlexList optBindings, int[] prefix, int shape)
          For this subtree and this index elements, 'shape' is the number of index elements that have been successfully enumerated.
abstract  int getHeight()
          Enabled: What's the longest distance to the bottom?
 SourceSpan getOptSpan()
          Enabled: What source text was originally lexed or parsed to produce this node, or a representative token of this node?
abstract  int matchBindSlice(ConstList args, ConstList specimenList, FlexList bindings, int[] index)
          Enabled:
abstract  void prettyPrintOn(TextWriter out)
          Enabled:
abstract  AstroArg qbuild(QuasiBuilder qbuilder)
          Enabled:
(package private) abstract  int startShape(ConstList args, FlexList optBindings, int[] prefix, int shapeSoFar)
          For this substree and this index-prefix, what's the most number of index elements that should be enumerated?
abstract  ConstList substSlice(ConstList args, int[] index)
          Enabled: @param args Each arg[i] is of a type matched to the corresponding dollar-hole.
 String toString()
          Suppressed:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.erights.e.elib.tables.Selfless
getSpreadUncall
 

Field Detail

serialVersionUID

static final long serialVersionUID

EMPTY_INDEX

static final int[] EMPTY_INDEX

EListGuard

static final ValueGuard EListGuard

myBuilder

final AstroBuilder myBuilder

myOptSpan

final SourceSpan myOptSpan
Constructor Detail

QAstroArg

public QAstroArg(AstroBuilder builder,
                 SourceSpan optSpan)
Enabled:

Parameters:
builder - For building the result of a substitute.
optSpan - Where is the source text this node was extracted from?
Method Detail

substSlice

public abstract ConstList substSlice(ConstList args,
                                     int[] index)
Enabled: @param args Each arg[i] is of a type matched to the corresponding dollar-hole. For example, if dollar-hole 3 (ie "${3}") has rank "?*+", then args[3] must be a list of lists of lists of terms, for which the outer list may only be zero or one long, the middle lists may be any length, and the inner lists must all have at least one element.

Parameters:
index - Further indexes after a hole's hole-num. For example, If a dollar-hole's hole-num is 3 and index is [4,5], then the dollar-hole would evaluate to args[3][4][5].
Returns:
:(ConstList of(Astro))

matchBindSlice

public abstract int matchBindSlice(ConstList args,
                                   ConstList specimenList,
                                   FlexList bindings,
                                   int[] index)
Enabled:

Parameters:
args - See the doc on 'args' in #substitute(Object[], String)
specimenList - :(ConstList of(Astro))
bindings - Like 'args', but by extraction from specimen
index - Further indexes after a hole's hole-num. For example, If a dollar-hole's hole-num is 3 and index is [4,5], then the dollar-hole would access args[3][4][5]. Similarly, an at-hole with hole-num 3 would store into bindings[3][4][5].
Returns:
How many elements of specimen are matched? Zero indicates a successful match of no elements, so -1 is used to instead indicate a failed match.

startShape

abstract int startShape(ConstList args,
                        FlexList optBindings,
                        int[] prefix,
                        int shapeSoFar)
For this substree and this index-prefix, what's the most number of index elements that should be enumerated?

If this subtree has no dollar-holes, it should just return shapeSoFar. The initial shapeSoFar is -1 (meaning "indeterminate"), so a tree with no dollar-holes will just return -1. An non-ranking inner node (eg, a QTerm) just asks all its children, passing to each the shapeSoFar from the previous.

All the rest of the semantics is specific to dollar-hole, at-hole, or to raking nodes, so see the documentation there.


endShape

abstract void endShape(FlexList optBindings,
                       int[] prefix,
                       int shape)
For this subtree and this index elements, 'shape' is the number of index elements that have been successfully enumerated.

For each prefix, startShape and endShape form the openning and closing brackets around calls to matchBindSlice or substSlice.


getOptSpan

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

Specified by:
getOptSpan in interface AstroArg

qbuild

public abstract AstroArg qbuild(QuasiBuilder qbuilder)
Enabled:


getHeight

public abstract 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 abstract void prettyPrintOn(TextWriter out)
                            throws IOException
Enabled:

IOException


comments?