orc.ast.extended.expression
Class Expression

java.lang.Object
  extended by orc.ast.extended.expression.Expression
All Implemented Interfaces:
ASTNode, Locatable, Located
Direct Known Subclasses:
AssertType, Call, Capsule, Catch, ConsExpr, Declare, Dot, Field, HasType, IfThenElse, Lambda, Let, ListExpr, Literal, Name, NilExpr, Otherwise, Parallel, Pruning, Sequential, Stop, Temporary, Throw

public abstract class Expression
extends java.lang.Object
implements ASTNode, Locatable

Base class for the extended abstract syntax tree. Extended expressions are produced by the parser with minimal processing. They desugar to a simplified set of expressions.

Author:
dkitchin, wcook

Nested Class Summary
static interface Expression.Arg
          Variant type returned by the argify method.
 
Constructor Summary
Expression()
           
 
Method Summary
protected  Expression.Arg argify()
          Simplify an expression which occurs in an argument (nested) position.
 SourceLocation getSourceLocation()
           
static java.lang.String join(java.util.Collection<?> items, java.lang.String separator)
          Utility method to join a sequence of items with a separator.
 void setSourceLocation(SourceLocation location)
           
abstract  Expression simplify()
          Simplify an expression which occurs in a call (non-nested) position.
static Expression uncurry(java.util.List<java.util.List<Pattern>> ps, Expression body)
          Utility method to fold a group of pattern lists into a lambda.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface orc.ast.extended.ASTNode
accept
 

Constructor Detail

Expression

public Expression()
Method Detail

simplify

public abstract Expression simplify()
                             throws CompilationException
Simplify an expression which occurs in a call (non-nested) position.

Returns:
The simplified expression
Throws:
CompilationException

argify

protected Expression.Arg argify()
                         throws CompilationException
Simplify an expression which occurs in an argument (nested) position. Returns an Arg, which produces an Argument for the simplified call, and may also introduce a binder, in the case of a nested expression. The default behavior is to act as a nested expression and produce a complexArg. Expressions which can validly occur in arg position on their own without a binder will override this behavior.

Returns:
The argified form of the expression
Throws:
CompilationException

setSourceLocation

public void setSourceLocation(SourceLocation location)
Specified by:
setSourceLocation in interface Locatable

getSourceLocation

public SourceLocation getSourceLocation()
Specified by:
getSourceLocation in interface ASTNode
Specified by:
getSourceLocation in interface Located

join

public static java.lang.String join(java.util.Collection<?> items,
                                    java.lang.String separator)
Utility method to join a sequence of items with a separator.


uncurry

public static Expression uncurry(java.util.List<java.util.List<Pattern>> ps,
                                 Expression body)
Utility method to fold a group of pattern lists into a lambda. If the pattern list is empty, just return b.

Parameters:
ps - list (P),...,(P)
body - b
Returns:
Expression lambda(P) = ( ... ( lambda(P) = b ) ... )