orc.ast.extended.declaration.def
Class Clause

java.lang.Object
  extended by orc.ast.extended.declaration.def.Clause

public class Clause
extends java.lang.Object


Field Summary
 Expression body
           
 java.util.List<Pattern> ps
           
 
Constructor Summary
Clause(java.util.List<Pattern> ps, Expression body)
           
 
Method Summary
 Expression simplify(java.util.List<Variable> formals, Expression otherwise)
          Simplify a clause.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ps

public java.util.List<Pattern> ps

body

public Expression body
Constructor Detail

Clause

public Clause(java.util.List<Pattern> ps,
              Expression body)
Method Detail

simplify

public Expression simplify(java.util.List<Variable> formals,
                           Expression otherwise)
                    throws CompilationException
Simplify a clause. This creates a new expression which will try to match the given formals against this clause's patterns. If the match succeeds, the clause body is executed with the bindings created by the pattern matches. If the match fails, the otherwise expression is executed. This function can be applied multiple times in sequence to make an expression which tries multiple clauses in linear order; see the translation of clausal definitions for an example.

Parameters:
formals - The formal arguments against which to match. These are created elsewhere, by some other translation step.
otherwise - The alternative expression to execute if the clause does not fire.
Returns:
A new expression which will try the clause, and then run the alternative if the clause fails to match.
Throws:
CompilationException