org.erights.e.elang.evm
Class ParseNode

java.lang.Object
  |
  +--org.erights.e.elang.evm.ParseNode
All Implemented Interfaces:
EPrintable, MatchMaker
Direct Known Subclasses:
ENode

public abstract class ParseNode
extends Object
implements MatchMaker, EPrintable

Safe: A ParseNode of a program written in "kernel E". A program written in E is immediately expanded to kernel E, hopefully passing source position through successfully.

XXX to be made DeepPassByCopy

Author:
Mark S. Miller

Field Summary
private  SourceSpan myOptSpan
          XXX to be made final
static int NUM_PR
          Enabled:
static int PR_ASSIGN
          Enabled:
static int PR_CALL
          Enabled:
static int PR_COMP
          Enabled:
static int PR_EEXPR
          Enabled: lowest priority expression
static int PR_LISTPATT
          Enabled:
static int PR_ORDER
          Enabled:
static int PR_PATTERN
          Enabled: lowest priority pattern
static int PR_PRIM
          Enabled: highest priority expression
static int PR_START
          Enabled: lowest priority
 
Constructor Summary
(package private) ParseNode(SourceSpan optSpan)
          A bit of a kludge, but we initialize the source after construction to avoid propogating source-tracking logic through all subclasses.
 
Method Summary
 void __printOn(TextWriter out)
          Enabled: Overridden in EExpr & Pattern
 String asText()
          Enabled: Without the surrounding "e`" and "`".
(package private)  void cleanCopy()
          Deprecated. Should instead have logic for making a copy that starts out clean.
 SourceSpan getOptSpan()
          Enabled: Where is the source code this syntactic construct was parsed from?
 void lnPrintOn(TextWriter out)
          Enabled: priority defaults to PR_START
 void lnPrintOn(TextWriter out, int priority)
          Enabled: Onto out, first print a newline, then spaces to the designated indent level, then pretty print this parse node.
 ConstList matchBind(ConstList args, Object specimen)
          Enabled:
abstract  boolean matchBind(ConstList args, Object specimen, FlexList bindings)
          Enabled:
(package private) static boolean matchBind(ParseNode[] templates, ConstList args, ParseNode[] specimens, FlexList bindings)
          Convenience method for matching corresponding arrays.
(package private) static boolean matchBind(ParseNode optTemplate, ConstList args, ParseNode optSpecimen, FlexList bindings)
          Convenience method for handling nulls.
static void printListOn(String left, ParseNode[] nodes, String sep, String right, TextWriter out, int priority)
          Enabled: Print the left bracket, then the nodes separated by sep, and then the right bracket
abstract  void subPrintOn(TextWriter out, int priority)
          Enabled: Pretty print this syntactic construct assuming the specified ambient indent level.
 String toString()
          Suppressed: For use in IDEs that invoke toString() from inside the debugger (at least VisualAge and IntelliJ IDEA).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PR_START

public static final int PR_START
Enabled: lowest priority


PR_EEXPR

public static final int PR_EEXPR
Enabled: lowest priority expression


PR_ASSIGN

public static final int PR_ASSIGN
Enabled:


PR_COMP

public static final int PR_COMP
Enabled:


PR_ORDER

public static final int PR_ORDER
Enabled:


PR_CALL

public static final int PR_CALL
Enabled:


PR_PRIM

public static final int PR_PRIM
Enabled: highest priority expression


PR_PATTERN

public static final int PR_PATTERN
Enabled: lowest priority pattern


PR_LISTPATT

public static final int PR_LISTPATT
Enabled:


NUM_PR

public static final int NUM_PR
Enabled:


myOptSpan

private SourceSpan myOptSpan
XXX to be made final

Constructor Detail

ParseNode

ParseNode(SourceSpan optSpan)
A bit of a kludge, but we initialize the source after construction to avoid propogating source-tracking logic through all subclasses.

Method Detail

cleanCopy

void cleanCopy()
Deprecated. Should instead have logic for making a copy that starts out clean.

Clear the source position.


lnPrintOn

public void lnPrintOn(TextWriter out)
               throws IOException
Enabled: priority defaults to PR_START

IOException

lnPrintOn

public void lnPrintOn(TextWriter out,
                      int priority)
               throws IOException
Enabled: Onto out, first print a newline, then spaces to the designated indent level, then pretty print this parse node. "subPrintOn" vs "lnPrintOn" is much like the conventional disctinction between "print" and "println", except that the newlines come first (hence the weird spelling), and the newline is followed by indentation.

IOException

matchBind

public abstract boolean matchBind(ConstList args,
                                  Object specimen,
                                  FlexList bindings)
Enabled:

Specified by:
matchBind in interface MatchMaker

matchBind

public ConstList matchBind(ConstList args,
                           Object specimen)
Enabled:

Specified by:
matchBind in interface MatchMaker

matchBind

static boolean matchBind(ParseNode[] templates,
                         ConstList args,
                         ParseNode[] specimens,
                         FlexList bindings)
Convenience method for matching corresponding arrays. null members must match exactly.


matchBind

static boolean matchBind(ParseNode optTemplate,
                         ConstList args,
                         ParseNode optSpecimen,
                         FlexList bindings)
Convenience method for handling nulls. nulls must match exactly.


getOptSpan

public SourceSpan getOptSpan()
Enabled: Where is the source code this syntactic construct was parsed from?


printListOn

public static void printListOn(String left,
                               ParseNode[] nodes,
                               String sep,
                               String right,
                               TextWriter out,
                               int priority)
                        throws IOException
Enabled: Print the left bracket, then the nodes separated by sep, and then the right bracket

IOException

subPrintOn

public abstract void subPrintOn(TextWriter out,
                                int priority)
                         throws IOException
Enabled: Pretty print this syntactic construct assuming the specified ambient indent level. The convention is that any leading or trailing whitespace (newlines, indentation, etc...) is handled by my caller. I just print from my first printing character to my last one, indenting as appropriate for internal newlines.

IOException

__printOn

public void __printOn(TextWriter out)
               throws IOException
Enabled: Overridden in EExpr & Pattern

Specified by:
__printOn in interface EPrintable
IOException
See Also:
subPrintOn(org.erights.e.elib.oldeio.TextWriter, int)

toString

public String toString()
Suppressed: For use in IDEs that invoke toString() from inside the debugger (at least VisualAge and IntelliJ IDEA).

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

asText

public String asText()
Enabled: Without the surrounding "e`" and "`".

Returns:


comments?