jfun.jaskell.ast
Class Exprs

java.lang.Object
  extended by jfun.jaskell.ast.Exprs

public final class Exprs
extends java.lang.Object

The class to create different Expr objects.

Author:
Ben Yu Dec 7, 2004

Constructor Summary
Exprs()
           
 
Method Summary
static Expr buildBinary(int from, Location loc, Expr e1, Expr op, Expr e2)
          Build a binary operator call where a function is used as an infix binary operator.
static Expr buildBinary(int from, Location loc, Expr e1, Operator op, Expr e2)
          Build a binary operator call.
static Expr buildBool(int from, Location loc, boolean b)
          Build an expression of a bool literal.
static Expr buildBound(int from, Location loc, Binding b)
          Create an expression for a compiled variable.
static Expr buildCall(int from, Location loc, Expr n, Expr[] args)
          Build a function call expression.
static Expr buildChar(int from, Location loc, java.lang.Character c)
          Build an expression of a char literal.
static Expr buildExpr(int from, Location loc, Expr e, FunBinding[] where)
          Build an expression with a list of compiled function definitions defined by "where".
static Expr buildExpr(int from, Location loc, Expr e, FunDef[] where)
          Build an expression with a list of function definitions defined by "where".
static Expr buildFieldUpdate(int from, Location loc, Expr e, Binding self, FunBinding[] flds)
          Build an expression for a compiled tuple field update.
static Expr buildFieldUpdate(int from, Location loc, Expr e, FunDef[] flds)
          Build an expression for tuple field update.
static Expr buildIf(int from, Location loc, Expr cond, Expr consequence)
          Build a if expression.
static Expr buildIfElse(int from, Location loc, Expr cond, Expr yes, Expr no)
          Build a if-else expression.
static Expr buildInteger(int from, Location loc, java.lang.Integer n)
          Build an expression of an integer literal.
static Expr buildInterpolatedString(int from, Location loc, InterpolatedString str)
          Build an expression of an interpolated string literal.
static Expr buildLamda(int from, Location loc, Alternative alt)
          Build an expression for lamda abstraction.
static Expr buildLamda(int from, Location loc, Param[] params, Expr body)
          Build an expression for lamda abstraction.
static Expr buildLet(int from, Location loc, FunBinding[] bindings)
          Build an expression with a list of compiled function definitions defined by "let"
static Expr buildLet(int from, Location loc, FunDef[] defs)
          Build an expression with a list of function definitions defined by "let".
static Expr buildList(int from, Location loc, Expr[] elems)
          Build an expression for a list.
static Expr buildMethodCall(int from, Location loc, Expr e, java.lang.String fname, Expr[] args)
          Build an expression for a tuple method call.
static Expr buildNumber(int from, Location loc, java.lang.Double n)
          Build an expression of a decimal number literal.
static Expr buildOpExpr(int from, Location loc, Operator f)
          Build an expression for an operator that is used as a function.
static Expr buildString(int from, Location loc, java.lang.String s)
          Build an expression of a string literal.
static Expr buildSubtuple(int from, Location loc, Expr e, java.lang.String[] flds)
          Build an expression for subtuple expression.
static Expr buildTuple(int from, Location loc, Binding self, FunBinding[] flds)
          Build an expression for tuple definition.
static Expr buildTuple(int from, Location loc, FunDef[] flds)
          Build an expression for tuple definition.
static Expr buildUnary(int from, Location loc, Operator op, Expr e)
          Build a unary operator call.
static Expr buildVar(int from, Location loc, java.lang.String n)
          Build an expression of a variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Exprs

public Exprs()
Method Detail

buildChar

public static Expr buildChar(int from,
                             Location loc,
                             java.lang.Character c)
Build an expression of a char literal.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
c - the character.
Returns:
the expression.

buildBool

public static Expr buildBool(int from,
                             Location loc,
                             boolean b)
Build an expression of a bool literal.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
b - the boolean value
Returns:
the expression.

buildNumber

public static Expr buildNumber(int from,
                               Location loc,
                               java.lang.Double n)
Build an expression of a decimal number literal.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
n - the number.
Returns:
the expression.

buildInteger

public static Expr buildInteger(int from,
                                Location loc,
                                java.lang.Integer n)
Build an expression of an integer literal.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
n - the integer.
Returns:
the expression.

buildString

public static Expr buildString(int from,
                               Location loc,
                               java.lang.String s)
Build an expression of a string literal.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
s - the string.
Returns:
the expression.

buildInterpolatedString

public static Expr buildInterpolatedString(int from,
                                           Location loc,
                                           InterpolatedString str)
Build an expression of an interpolated string literal.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
str - the string literal.
Returns:
the expression.

buildVar

public static Expr buildVar(int from,
                            Location loc,
                            java.lang.String n)
Build an expression of a variable.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
n - the variable name.
Returns:
the expression.

buildOpExpr

public static Expr buildOpExpr(int from,
                               Location loc,
                               Operator f)
Build an expression for an operator that is used as a function.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
f - the operator.
Returns:
the expression.

buildCall

public static Expr buildCall(int from,
                             Location loc,
                             Expr n,
                             Expr[] args)
Build a function call expression.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
n - the function.
args - the arguments.
Returns:
the expression.

buildIfElse

public static Expr buildIfElse(int from,
                               Location loc,
                               Expr cond,
                               Expr yes,
                               Expr no)
Build a if-else expression.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
cond - the condition.
yes - the expression when cond is true.
no - the expression when cond is false.
Returns:
the expression.

buildIf

public static Expr buildIf(int from,
                           Location loc,
                           Expr cond,
                           Expr consequence)
Build a if expression.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
cond - the condition.
consequence - the expression when cond is true.
Returns:
the expression.

buildUnary

public static Expr buildUnary(int from,
                              Location loc,
                              Operator op,
                              Expr e)
Build a unary operator call.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
op - the operator.
e - the operand.
Returns:
the expression.

buildBinary

public static Expr buildBinary(int from,
                               Location loc,
                               Expr e1,
                               Operator op,
                               Expr e2)
Build a binary operator call.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
e1 - the left operand.
op - the operator.
e2 - the right operand.
Returns:
the expression.

buildBinary

public static Expr buildBinary(int from,
                               Location loc,
                               Expr e1,
                               Expr op,
                               Expr e2)
Build a binary operator call where a function is used as an infix binary operator.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
e1 - the left operand.
op - the function used as operator.
e2 - the right operand.
Returns:
the expression.

buildExpr

public static Expr buildExpr(int from,
                             Location loc,
                             Expr e,
                             FunDef[] where)
Build an expression with a list of function definitions defined by "where".

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
e - the expression.
where - the function definitions defined after "where".
Returns:
the result expression.

buildExpr

public static Expr buildExpr(int from,
                             Location loc,
                             Expr e,
                             FunBinding[] where)
Build an expression with a list of compiled function definitions defined by "where".

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
e - the expression.
where - the compiled function definitions.
Returns:
the result expression.

buildLet

public static Expr buildLet(int from,
                            Location loc,
                            FunDef[] defs)
Build an expression with a list of function definitions defined by "let".

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
Returns:
the result expression.

buildLet

public static Expr buildLet(int from,
                            Location loc,
                            FunBinding[] bindings)
Build an expression with a list of compiled function definitions defined by "let"

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
bindings - the compiled function definitions.
Returns:
the result expression.

buildBound

public static Expr buildBound(int from,
                              Location loc,
                              Binding b)
Create an expression for a compiled variable.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
b - the binding that it binds to.
Returns:
the expression.

buildTuple

public static Expr buildTuple(int from,
                              Location loc,
                              FunDef[] flds)
Build an expression for tuple definition.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
flds - the tuple field definitions.
Returns:
the result expression.

buildTuple

public static Expr buildTuple(int from,
                              Location loc,
                              Binding self,
                              FunBinding[] flds)
Build an expression for tuple definition.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
flds - the compiled tuple field definitions.
Returns:
the result expression.

buildList

public static Expr buildList(int from,
                             Location loc,
                             Expr[] elems)
Build an expression for a list.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
elems - the expressions for each list item.
Returns:
the result expression.

buildMethodCall

public static Expr buildMethodCall(int from,
                                   Location loc,
                                   Expr e,
                                   java.lang.String fname,
                                   Expr[] args)
Build an expression for a tuple method call.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
e - the tuple expression.
fname - the field/method name.
args - the arguments.
Returns:
the result expression.

buildFieldUpdate

public static Expr buildFieldUpdate(int from,
                                    Location loc,
                                    Expr e,
                                    Binding self,
                                    FunBinding[] flds)
Build an expression for a compiled tuple field update.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
e - the tuple expression.
self - the binding for the special "this" variable that may be used inside the tuple definition.
flds - the new compiled tuple field definitions.
Returns:
the result expression.

buildFieldUpdate

public static Expr buildFieldUpdate(int from,
                                    Location loc,
                                    Expr e,
                                    FunDef[] flds)
Build an expression for tuple field update.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
e - the tuple expression.
flds - the new field definitions.
Returns:
the result expression.

buildLamda

public static Expr buildLamda(int from,
                              Location loc,
                              Alternative alt)
Build an expression for lamda abstraction.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
alt - the Alternative object that represents this lamda definition.
Returns:
the result expression.

buildLamda

public static Expr buildLamda(int from,
                              Location loc,
                              Param[] params,
                              Expr body)
Build an expression for lamda abstraction.

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
params - the parameters of the lamda abstraction.
body - the body of the lamda abstraction.
Returns:
the result expression.

buildSubtuple

public static Expr buildSubtuple(int from,
                                 Location loc,
                                 Expr e,
                                 java.lang.String[] flds)
Build an expression for subtuple expression. example: mytuple.{fld1, fld2, fld3}

Parameters:
from - the starting index of this expression in the original source.
loc - the location of this expression in the original source.
e - the expression for the tuple.
flds - the tuple members selected.
Returns:
the subtuple expression.