org.erights.e.elang.syntax
Class ENodeBuilder

java.lang.Object
  |
  +--org.erights.e.elang.syntax.BaseENodeBuilder
        |
        +--org.erights.e.elang.syntax.ENodeBuilder
All Implemented Interfaces:
BaseEBuilder, EBuilder

public class ENodeBuilder
extends BaseENodeBuilder
implements EBuilder

Untamed:


Field Summary
private static EExpr __BREAK
           
private static EExpr __CONTINUE
           
private static EExpr __RETURN
           
private static EExpr ANY
           
private static EExpr BOOLEAN
           
private static EExpr COMPARER
           
private static EExpr DEFINESLOT
           
private static EExpr EE
           
private static EExpr EQUALIZER
           
private static EExpr FALSE
           
private static EExpr LOOP
           
private static EExpr MAKE_LIST
           
private static EExpr MAKE_MAP
           
private static EExpr MAKE_MSG
           
private static EExpr MAKE_ORDERED_SPACE
           
private static EExpr MAKE_PARAM
           
private static EExpr MAKE_PROT
           
private  HilbertHotel myHilbert
           
private static EExpr[] NO_EEXPRS
           
private static EExpr NULL
           
private static EExpr PROMISE_ALL_FULFILLED
           
private static EExpr REF
           
private static EExpr SETTABLE
           
private static EExpr THROW
           
private static EExpr TRUE
           
private static EExpr VOID
           
 
Fields inherited from class org.erights.e.elang.syntax.BaseENodeBuilder
myLexer, myProps
 
Constructor Summary
ENodeBuilder(ConstMap props, LexerFace lexer)
          Enabled:
 
Method Summary
 Object[] accumBody(Object verb, Object rnValue)
          Enabled:
 Object[] accumFor(Object assoc, Object collExpr, Object accumBody)
          Enabled:
 Object[] accumIf(Object condExpr, Object accumBody)
          Enabled:
 EExpr accumulate(Object starterExpr, Object accumulator)
          Enabled:
 Object[] accumWhile(Object condExpr, Object accumBody)
          Enabled:
private  EExpr[] antiCycle(FlexMap conflicts)
          Expand a left-pattern and an rValue that might cause a circularity into a sequence of expressions without this circularity, except that the place for the expression itself has a null as a placeholder.
 EExpr asBigAs(Object x, Object y)
          Enabled:
 EExpr assign(Object lValue, Object rValue)
          Enabled:
 Assoc assoc(Object key, Object value)
          Enabled:
 Pattern atNoun(Object token)
          Enabled: When an at-hole is '@' or '@_'
 Pattern bindDefiner(Object identOrStr)
          Enabled:
 Pattern bindDefiner(Object identOrStr, Object valueGuardExpr)
          Enabled:
 EExpr call(Object recipientExpr, Object verbPos, String verb, Object args)
          Enabled:
 EExpr classExpr(Object doco, Object classHead, Object mBody)
          Enabled:
 EExpr condAnd(Object left, Object right)
          Enabled: left && right => { if (left) { if (right) { [&nameOut, ...] } else { null } } else { null } } =~ [&nameOut, ...]
 EExpr condOr(Object left, Object right)
          Enabled: left || right => { if (left) { null =~ [right's outNames - left's outNames] [&nameOut, ...] } else if (right) { null =~ [left's outNames - right's outNames] [&nameOut, ...] } else { null } } =~ [&nameOut, ...]
 EExpr define(Object pattern, Object rValue)
          Enabled:
 Matcher delegatex(Object bodyExpr)
          Enabled: delegate{expr} expands to match [verb, args] { E call(expr, verb, args) }
 EExpr dollarNoun(Object token)
          Enabled: When a dollar-hole is '$'
 EExpr doMeta(Object keyword, Object verb, Object args)
          Enabled:
 EExpr doMeta(Object keyword, Object verbPos, String verb, Object args)
          Enabled:
 EExpr doMetaSend(Object keyword, Object verb, Object args)
          Enabled:
 EExpr doMetaSend(Object keyword, Object verbPos, String verb, Object args)
          Enabled:
 EExpr ejector(Object ejNoun)
          Enabled:
 EExpr ejector(Object ejNoun, Object valExpr)
          Enabled:
 Assoc exporter(Object nounExpr)
          Enabled:
 Pattern finalPattern(Object str)
          Enabled:
 EExpr forward(Object identOrStr)
          Enabled: A forward declaration.
 EExpr forx(Object assoc, Object collExpr, Object mBody)
          Enabled:
 EExpr geq(Object x, Object y)
          Enabled:
 EExpr get__BREAK()
          Enabled:
 EExpr get__CONTINUE()
          Enabled:
 EExpr get__RETURN()
          Enabled:
 EExpr getNULL()
          Enabled:
 EExpr getVOID()
          Enabled:
 EExpr greaterThan(Object x, Object y)
          Enabled:
private  Astro ident(Object original, String newStr)
          Makes an identifier token whose value is 'newStr', and whose source is derived from 'original'.
 EExpr ifx(Object condExpr, Object thenExpr)
          Enabled:
 Assoc importer(Object namerPatt)
          Enabled:
 EExpr leq(Object x, Object y)
          Enabled:
 EExpr lessThan(Object x, Object y)
          Enabled:
private  EExpr[] lValuePair(EExpr lValue)
          Return a pair of an optional prelude expression and an access expression, used to access of modify an lValue without recomputing the lValue expression.
 EExpr macro(Object macroName, Object optMacroArg, Object macroBody, Object optNextMacro)
          Enabled:
 Astro mangle(Object ident, String suffix)
          Enabled: Mangles an identifier into a variable name by appending a known suffix.
 EExpr map(Object assocList)
          Enabled: [a => b, c => d] expands to __makeMap fromPairs([[a, b], [c, d]) This exapansion satisfies the requirement that it preserves order.
 Pattern mapPattern(Object assocList, Object optRestPatt)
          Enabled:
private  EExpr matchExpr(Matcher[] matchers, Astro varName, EExpr optOtherwise)
           
 EExpr methObject(Object decl, Object msgPatt, Object bodyExpr, boolean bindReturn)
          Enabled: For defining an eScript that consists of exactly one method
private  EScriptDecl methScriptDecl(Object msgPatt, Object bodyExpr, boolean bindReturn)
          For defining an eScript that consists of exactly one method
 EExpr mod(Object val, Object nModulus)
          Enabled:
 EExpr mType(Object doco, Object verb, Object pTypes, Object optRetType)
          Enabled:
private  Astro newTemp(Object identOrString)
          generate 'unique' temporary variable names for transformations.
 EExpr not(Object x)
          Enabled:
 EExpr object(Object decl, Object script)
          Enabled:
private  EExpr object(String docComment, Object optOName, EExpr optSuperExpr, EExpr[] impls, EScriptDecl script)
           
 ObjDecl oDecl(Object optExtends, Object auditors)
          Enabled:
 ObjDecl oDecl(Object doco, Object optOName, Object oldODecl)
          Enabled:
(package private)  Matcher optMatcher(Object matchers)
           
private  EExpr oType(LiteralExpr docComment, Object optOName, Pattern optAuditorPatt, EExpr optExtends, EExpr auditorTuple, EExpr msgTuple)
           
 EExpr oType(Object doco, Object oName, Object mTypes)
          Enabled:
 EExpr oType(Object doco, Object optOName, Object optAudit, Object decl, Object mTypes)
          Enabled:
private  EExpr oTypeBase(LiteralExpr docComment, Pattern optGuardPatt, Pattern optAuditorPatt, EExpr qualName, EExpr auditorTuple, EExpr msgTuple)
           
 Pattern patternEquals(Object eExpr)
          Enabled: (== eExpr) expands to (specimen ? specimen == eExpr)
 Astro prop(Object propertyName)
          Enabled: Used to transform 'a.name' into 'a.getName(args)'.
 EExpr pType(Object optName, Object optType)
          Enabled:
 EExpr quasiExpr(Object syntax, Object quasiList)
          Enabled: syntax`foo $bar baz $zip zorp` expands to syntax_quasiParser \ valueMaker("foo ${0} baz ${1} zorp") \ substitute([bar, zip])
 QuasiLiteralExpr quasiLiteralExpr()
          Enabled: $$ expands to ${0}
 QuasiLiteralExpr quasiLiteralExpr(Object litIndex)
          Enabled:
 QuasiLiteralPatt quasiLiteralPatt(Object litIndex)
          Enabled:
 Pattern quasiPattern(Object syntax, Object quasiList)
          Enabled: syntax`foo $bar baz @zip zorp` expands to q ? (syntax__quasiParser \ matchMaker("foo ${0} baz @{0} zorp") \ matchBind([bar], q) =~ [zip])
 QuasiPatternExpr quasiPatternExpr(Object litIndex)
          Enabled:
 QuasiPatternPatt quasiPatternPatt(Object litIndex)
          Enabled:
 EExpr same(Object x, Object y)
          Enabled:
 EExpr send(Object recipientExpr, Object verbPos, String verb, Object args)
          Enabled:
 EExpr sequence(Object x, Object y)
          Enabled:
 EExpr sequence(Object x, Object y, Object z)
          Enabled:
 Pattern slotDefiner(Object name)
          Enabled:
 EExpr slotExpr(Object eExpr)
          Enabled:
private  Pattern slotsPattern(Object[] names)
          Given an array of names, return a tuple pattern that will bind all these names to slots when matched with an array of slots with the same shape.
private  EExpr slotsTuple(Object[] names)
          Given an array of names, return an expression that will make a tuple from the slots of the variables of these names
 EExpr switchx(Object specimen, Object matchers)
          Enabled: switch (eExpr) { match pattern1 { body1 } match pattern2 { body2 } } expands to { def temp = eExpr if (temp =~ pattern1) { body1 } else if (temp =~ pattern2) { body2 } else { throw("no match: " + temp) } }
 EExpr thru(Object start, Object stop)
          Enabled:
 EExpr thunk(Object doco, Object bodyExpr)
          Enabled: Expands to
 EExpr till(Object start, Object bound)
          Enabled:
 EMethodNode to(Object doco, Object msgPatt, Object bodyExpr)
          Enabled:
 EExpr tryx(Object eExpr, Object catchers, Object optFinally)
          Enabled:
 EExpr tuple(Object argList)
          Enabled: [x, y, z] expands to __makeList(x, y, z)
 EExpr update(Object lValue, Object verb, Object rnValue)
          Enabled:
 EExpr uriExpr(Object uriToken)
          Enabled: uriToken must be a URI, and have both protocol and body.
 EExpr uriExpr(Object uriStartToken, Object uriBodyExpr)
          Enabled: uriStartToken must be a URIStart, and must have a protocol, but no body.
 Astro varName(Object identOrStr)
          Enabled: Make vacancies for new temporary variable names.
 Pattern varPattern(Object name)
          Enabled:
 EExpr when(Object headList, Object bodyExpr, Object catchers, Object optFinally)
          Enabled:
private  EExpr whenBase(EExpr eExpr, ObjDecl objDecl, Pattern patt1, EExpr resultGuard, EExpr body1, Object catchers, Object optFinally)
          Then when statement base-case expands as follows:
private  EExpr whenList(EExpr[] eExprs, ObjDecl objDecl, Pattern[] patts, EExpr resultGuard, EExpr body1, Object catchers, Object optFinally)
          Then normal when statement syntax expands as follows:
 EExpr whilex(Object condExpr, Object bodyExpr)
          Enabled: The while loop expands as follows: while (cond) { body } expands to escape __break { __loop( def _() :boolean { if (cond) { escape __continue { body } true } else { false } }) }
 
Methods inherited from class org.erights.e.elang.syntax.BaseENodeBuilder
antiPocket, append, call, cdrPattern, docComment, escape, exprs, finalPattern, hide, ident, idStr, ifx, ignore, list, list, list, list, list, listPattern, literal, matchBind, matcher, methHead, method, noun, object, oDecl, pocket, reserved, send, sequence, suchThat, syntaxError, typedArray, varPattern, vTable, with
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.erights.e.elang.syntax.BaseEBuilder
antiPocket, append, call, cdrPattern, escape, finalPattern, hide, ifx, ignore, list, list, list, list, list, listPattern, literal, matchBind, matcher, methHead, method, oDecl, pocket, reserved, send, sequence, suchThat, varPattern, vTable, with
 

Field Detail

NULL

private static final EExpr NULL

FALSE

private static final EExpr FALSE

TRUE

private static final EExpr TRUE

THROW

private static final EExpr THROW

LOOP

private static final EExpr LOOP

MAKE_LIST

private static final EExpr MAKE_LIST

MAKE_MAP

private static final EExpr MAKE_MAP

MAKE_PROT

private static final EExpr MAKE_PROT

MAKE_MSG

private static final EExpr MAKE_MSG

MAKE_PARAM

private static final EExpr MAKE_PARAM

SETTABLE

private static final EExpr SETTABLE

DEFINESLOT

private static final EExpr DEFINESLOT

ANY

private static final EExpr ANY

VOID

private static final EExpr VOID

BOOLEAN

private static final EExpr BOOLEAN

MAKE_ORDERED_SPACE

private static final EExpr MAKE_ORDERED_SPACE

EQUALIZER

private static final EExpr EQUALIZER

COMPARER

private static final EExpr COMPARER

REF

private static final EExpr REF

EE

private static final EExpr EE

PROMISE_ALL_FULFILLED

private static final EExpr PROMISE_ALL_FULFILLED

__BREAK

private static final EExpr __BREAK

__CONTINUE

private static final EExpr __CONTINUE

__RETURN

private static final EExpr __RETURN

NO_EEXPRS

private static final EExpr[] NO_EEXPRS

myHilbert

private final HilbertHotel myHilbert
Constructor Detail

ENodeBuilder

public ENodeBuilder(ConstMap props,
                    LexerFace lexer)
Enabled:

Method Detail

getNULL

public EExpr getNULL()
Enabled:

Specified by:
getNULL in interface EBuilder

getVOID

public EExpr getVOID()
Enabled:

Specified by:
getVOID in interface EBuilder

get__BREAK

public EExpr get__BREAK()
Enabled:

Specified by:
get__BREAK in interface EBuilder

get__CONTINUE

public EExpr get__CONTINUE()
Enabled:

Specified by:
get__CONTINUE in interface EBuilder

get__RETURN

public EExpr get__RETURN()
Enabled:

Specified by:
get__RETURN in interface EBuilder

assign

public EExpr assign(Object lValue,
                    Object rValue)
Enabled:

Specified by:
assign in interface BaseEBuilder
Overrides:
assign in class BaseENodeBuilder

lValuePair

private EExpr[] lValuePair(EExpr lValue)
Return a pair of an optional prelude expression and an access expression, used to access of modify an lValue without recomputing the lValue expression.

In expanding

     x[foo()][bar()] += 3
it's important that x[foo()] and bar() only be evaluated once. This evaluation happens in the prelude, leaving the resulting values in temporary variables, let's say t1 and t2 used by the access expression.

The access expression would then be t1[t2], ie, t1.get(t2). By the assignment rules, when such an expression appears on the left side of an assignment, it gets transformed approximately into t1.put(t2, newValue). (Actually, the assignment transform also arranges for the value of the assignment to be the value the rValue evaluated to.)

lValuePair can only be applied to NounExprs and CallExprs.


update

public EExpr update(Object lValue,
                    Object verb,
                    Object rnValue)
Enabled:

Specified by:
update in interface EBuilder

slotExpr

public EExpr slotExpr(Object eExpr)
Enabled:

Specified by:
slotExpr in interface BaseEBuilder
Overrides:
slotExpr in class BaseENodeBuilder

call

public EExpr call(Object recipientExpr,
                  Object verbPos,
                  String verb,
                  Object args)
Enabled:

Specified by:
call in interface EBuilder

send

public EExpr send(Object recipientExpr,
                  Object verbPos,
                  String verb,
                  Object args)
Enabled:

Specified by:
send in interface EBuilder

not

public EExpr not(Object x)
Enabled:

Specified by:
not in interface EBuilder

doMeta

public EExpr doMeta(Object keyword,
                    Object verb,
                    Object args)
Enabled:

Specified by:
doMeta in interface EBuilder

doMeta

public EExpr doMeta(Object keyword,
                    Object verbPos,
                    String verb,
                    Object args)
Enabled:

Specified by:
doMeta in interface EBuilder

doMetaSend

public EExpr doMetaSend(Object keyword,
                        Object verb,
                        Object args)
Enabled:

Specified by:
doMetaSend in interface EBuilder

doMetaSend

public EExpr doMetaSend(Object keyword,
                        Object verbPos,
                        String verb,
                        Object args)
Enabled:

Specified by:
doMetaSend in interface EBuilder

classExpr

public EExpr classExpr(Object doco,
                       Object classHead,
                       Object mBody)
Enabled:

Specified by:
classExpr in interface EBuilder

condAnd

public EExpr condAnd(Object left,
                     Object right)
Enabled: left && right => { if (left) { if (right) { [&nameOut, ...] } else { null } } else { null } } =~ [&nameOut, ...]

Specified by:
condAnd in interface EBuilder

condOr

public EExpr condOr(Object left,
                    Object right)
Enabled: left || right => { if (left) { null =~ [right's outNames - left's outNames] [&nameOut, ...] } else if (right) { null =~ [left's outNames - right's outNames] [&nameOut, ...] } else { null } } =~ [&nameOut, ...]

Specified by:
condOr in interface EBuilder

antiCycle

private EExpr[] antiCycle(FlexMap conflicts)
Expand a left-pattern and an rValue that might cause a circularity into a sequence of expressions without this circularity, except that the place for the expression itself has a null as a placeholder.


define

public EExpr define(Object pattern,
                    Object rValue)
Enabled:

Specified by:
define in interface BaseEBuilder
Overrides:
define in class BaseENodeBuilder

atNoun

public Pattern atNoun(Object token)
Enabled: When an at-hole is '@' or '@_'

Specified by:
atNoun in interface EBuilder

finalPattern

public Pattern finalPattern(Object str)
Enabled:

Specified by:
finalPattern in interface EBuilder

varPattern

public Pattern varPattern(Object name)
Enabled:

Specified by:
varPattern in interface EBuilder

slotDefiner

public Pattern slotDefiner(Object name)
Enabled:

Specified by:
slotDefiner in interface EBuilder

dollarNoun

public EExpr dollarNoun(Object token)
Enabled: When a dollar-hole is '$'

Specified by:
dollarNoun in interface EBuilder

ident

private Astro ident(Object original,
                    String newStr)
Makes an identifier token whose value is 'newStr', and whose source is derived from 'original'.

'original' might be a String, an identifier token (an Astro), a CallExpr, or a SendExpr.