org.quasiliteral.quasiterm
Class QSome

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

public class QSome
extends QAstroArg

Untamed:

Author:
Mark S. Miller
See Also:
Serialized Form

Field Summary
private  QAstroArg myOptSubPattern
           
private  char myQuant
           
static StaticMaker QSomeMaker
          Enabled:
(package private) static long serialVersionUID
           
 
Fields inherited from class org.quasiliteral.quasiterm.QAstroArg
EListGuard, EMPTY_INDEX, myBuilder, myOptSpan
 
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
QSome(AstroBuilder builder, QAstroArg optSubPattern, char quant, SourceSpan optSpan)
          Enabled:
 
Method Summary
(package private)  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.
 int getHeight()
          Enabled: If I have a sub-pattern, my height is the same as its.
 Object[] getSpreadUncall()
          Enabled: Uses 'QSomeMaker(myBuilder, myOptSubPattern, myQuant, myOptSpan)'
private static boolean inBounds(int num, char quant)
           
 int matchBindSlice(ConstList args, ConstList specimenList, FlexList bindings, int[] index)
          Enabled:
 void prettyPrintOn(TextWriter out)
          Enabled:
 AstroArg qbuild(QuasiBuilder qbuilder)
          Enabled:
(package private)  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?
 ConstList substSlice(ConstList args, int[] index)
          Enabled:
 
Methods inherited from class org.quasiliteral.quasiterm.QAstroArg
__printOn, asText, getOptSpan, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID

QSomeMaker

public static final StaticMaker QSomeMaker
Enabled:


myOptSubPattern

private final QAstroArg myOptSubPattern

myQuant

private final char myQuant
Constructor Detail

QSome

public QSome(AstroBuilder builder,
             QAstroArg optSubPattern,
             char quant,
             SourceSpan optSpan)
Enabled:

Parameters:
quant - One of '?', '+', or '*'.
Method Detail

getSpreadUncall

public Object[] getSpreadUncall()
Enabled: Uses 'QSomeMaker(myBuilder, myOptSubPattern, myQuant, myOptSpan)'


inBounds

private static boolean inBounds(int num,
                                char quant)

substSlice

public ConstList substSlice(ConstList args,
                            int[] index)
Enabled:

Specified by:
substSlice in class QAstroArg
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 int matchBindSlice(ConstList args,
                          ConstList specimenList,
                          FlexList bindings,
                          int[] index)
Enabled:

Specified by:
matchBindSlice in class QAstroArg
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

int startShape(ConstList args,
               FlexList optBindings,
               int[] prefix,
               int shapeSoFar)
Description copied from class: QAstroArg
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.

Specified by:
startShape in class QAstroArg

endShape

void endShape(FlexList optBindings,
              int[] prefix,
              int shape)
Description copied from class: QAstroArg
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.

Specified by:
endShape in class QAstroArg

qbuild

public AstroArg qbuild(QuasiBuilder qbuilder)
Enabled:

Specified by:
qbuild in class QAstroArg

getHeight

public int getHeight()
Enabled: If I have a sub-pattern, my height is the same as its.

Otherwise, my height is 1, which is the height of a leaf.

Specified by:
getHeight in class QAstroArg

prettyPrintOn

public void prettyPrintOn(TextWriter out)
                   throws IOException
Enabled:

Specified by:
prettyPrintOn in class QAstroArg
IOException


comments?