org.quasiliteral.term
Class TermBuilder

java.lang.Object
  |
  +--org.quasiliteral.astro.BaseBuilder
        |
        +--org.quasiliteral.term.TermBuilder
All Implemented Interfaces:
AstroBuilder

public class TermBuilder
extends BaseBuilder

Untamed: Builds Term/Functor trees.

The type parameters of AstroBuilder are bound as follows:

     Leaf -- Functor
     Node -- Term
     Arg -- Term
     Args -- a FlexList of Term
 

Author:
Mark S. Miller

Field Summary
static TermBuilder FOR_TERMS
          Enabled: Builds Term trees according to the term.y grammar
 
Fields inherited from class org.quasiliteral.astro.BaseBuilder
 
Constructor Summary
TermBuilder(AstroSchema schema)
          Enabled:
 
Method Summary
 Astro composite(AstroTag tag, Object data, SourceSpan optSpan)
          Enabled: For Terms, this is non-atomic
protected  Astro leafInternal(AstroTag tag, Object optData, SourceSpan optSpan)
          Actually makes the kind of leaf this builder makes.
 Object list()
          Enabled: Returns a new empty FlexList that can be consumed by further productions.
 Astro term(Astro functor, Object args)
          Enabled: @param functor :Term with no arguments
 String toString()
          Suppressed:
 Object with(Object list, AstroArg next)
          Enabled: 'list' is consumed (should no longer be considered valid by the caller) in order to efficiently produce the output.
 
Methods inherited from class org.quasiliteral.astro.BaseBuilder
bag, getSchema, leafChar, leafData, leafFloat64, leafInteger, leafLong, leafString, leafTag, leafTwine, list, list, list, list, start, term, tuple, unpack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FOR_TERMS

public static final TermBuilder FOR_TERMS
Enabled: Builds Term trees according to the term.y grammar

Constructor Detail

TermBuilder

public TermBuilder(AstroSchema schema)
Enabled:

Method Detail

toString

public String toString()
Suppressed:

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

leafInternal

protected Astro leafInternal(AstroTag tag,
                             Object optData,
                             SourceSpan optSpan)
Description copied from class: BaseBuilder
Actually makes the kind of leaf this builder makes.

This is '*Internal' and 'protected' because it assumes that the general invariants among the arguments are already ensured. It is up to the callers of leafInternal to ensure this.

Specified by:
leafInternal in class BaseBuilder
Parameters:
tag - Identifies a token type in a particular grammar or set of related grammars.
optData - null, or a Character, BigInteger, Double, or Twine presumably calculated from lexing this token. If not null, then if the tag is the corresponding literal-type-tag, then this is still a leaf. Otherwise, it's a composite.

composite

public Astro composite(AstroTag tag,
                       Object data,
                       SourceSpan optSpan)
Enabled: For Terms, this is non-atomic

Specified by:
composite in interface AstroBuilder
Overrides:
composite in class BaseBuilder
Parameters:
data - Nust not be null
Returns:
:AstroToken

term

public Astro term(Astro functor,
                  Object args)
Enabled: @param functor :Term with no arguments

Parameters:
args - :(EList of(Term))
Returns:
:Term

list

public Object list()
Enabled: Returns a new empty FlexList that can be consumed by further productions.

Returns:
:(FlexList of(Term))

with

public Object with(Object list,
                   AstroArg next)
Enabled: 'list' is consumed (should no longer be considered valid by the caller) in order to efficiently produce the output.

In fact, this simply pushes 'next' onto 'list' and returns 'list'

Parameters:
list - :(EList of(Term))
next - :Term
Returns:
:(FlexList of(Term))


comments?