org.erights.e.elang.visitors
Interface ETreeVisitor

All Known Implementing Classes:
CapSlang2JVisitor, KernelECopyVisitor, SmallcapsEncoderVisitor

public interface ETreeVisitor

Untamed:


Method Summary
 Object visitAssignExpr(ENode optOriginal, AtomicExpr noun, EExpr rValue)
          Enabled: varName ":=" rValue.
 Object visitCallExpr(ENode optOriginal, EExpr recip, String verb, EExpr[] args)
          Enabled: recip verb "(" args*, ")".
 Object visitCatchExpr(ENode optOriginal, EExpr attempt, Pattern patt, EExpr catcher)
          Enabled: "try" "{" attempt "}" "catch" patt "{" catcher "}".
 Object visitCdrPattern(ENode optOriginal, ListPattern subs, Pattern rest)
          Enabled: listPattern "+" pattern
 Object visitDefineExpr(ENode optOriginal, Pattern patt, EExpr rValue)
          Enabled: "def" patt ":=" rValue.
 Object visitEMethod(ENode optOriginal, String docComment, String verb, Pattern[] patterns, EExpr returnGuard, EExpr body)
          Enabled: "##" docComment
"to" verb "(" patterns*, ")" ":" returnGuard "{" body "}".
 Object visitEscapeExpr(ENode optOriginal, Pattern hatch, EExpr body)
          Enabled: "escape" hatch "{" body "}".
 Object visitEScript(ENode optOriginal, EMethodNode[] optMethods, Matcher optMatcher)
          Enabled: "{" methods* matcher? "}"? XXX currently, when a matcher should have been provided to visitObjectExpr, instead an eScript is provided whose optMethods is null.
 Object visitFinallyExpr(ENode optOriginal, EExpr attempt, EExpr unwinder)
          Enabled: "try" "{" attempt "}" "finally" "{" unwinder "}".
 Object visitFinalPattern(ENode optOriginal, String varName, EExpr valueGuardExpr)
          Enabled: varName (":" valueGuardExpr)?.
 Object visitHideExpr(ENode optOriginal, EExpr body)
          Enabled: "{" body "}".
 Object visitIfExpr(ENode optOriginal, EExpr test, EExpr then, EExpr els)
          Enabled: "if" "("test")" "{" then "}" "else" "{" els "}".
 Object visitIgnorePattern(ENode optOriginal)
          Enabled: "_".
 Object visitListPattern(ENode optOriginal, Pattern[] subs)
          Enabled: "["pattern*, "]".
 Object visitLiteralExpr(ENode optOriginal, Object value)
          Enabled: value.
 Object visitMatchBindExpr(ENode optOriginal, EExpr specimen, Pattern patt)
          Enabled: specimen "=~" patt.
 Object visitMatcher(ENode optOriginal, Pattern pattern, EExpr body)
          Enabled: "match" pattern "{" body "}".
 Object visitNounExpr(ENode optOriginal, String varName)
          Enabled: varName.
 Object visitObjectExpr(ENode optOriginal, String docComment, String optFQN, EExpr[] auditors, EScript eScript)
          Enabled: "##" synopsys "def" string-literal ("implements" auditors)? (eScript | matcher)
 Object visitQuasiLiteralExpr(ENode optOriginal, int index)
          Enabled: "$" "{" index "}".
 Object visitQuasiLiteralPatt(ENode optOriginal, int index)
          Enabled: "$" "{" index "}".
 Object visitQuasiPatternExpr(ENode optOriginal, int index)
          Enabled: "@" "{" index "}".
 Object visitQuasiPatternPatt(ENode optOriginal, int index)
          Enabled: "@" "{" index "}".
 Object visitScopeExpr(ENode optOriginal)
          Enabled: "meta" "scope".
 Object visitSendExpr(ENode optOriginal, EExpr recip, String verb, EExpr[] args)
          Enabled: recip "<-" verb "(" args*, ")".
 Object visitSeqExpr(ENode optOriginal, EExpr[] subs)
          Enabled: first "\n" second.
 Object visitSlotExpr(ENode optOriginal, AtomicExpr noun)
          Enabled: "&" varName.
 Object visitSuchThatPattern(ENode optOriginal, Pattern patt, EExpr test)
          Enabled: patt "?" test.
 Object visitVarPattern(ENode optOriginal, String varName, EExpr slotGuardExpr)
          Enabled: var varName (":" slotGuardExpr)?.
 

Method Detail

visitAssignExpr

public Object visitAssignExpr(ENode optOriginal,
                              AtomicExpr noun,
                              EExpr rValue)
Enabled: varName ":=" rValue.

Does a setValue on the slot named by varName to the value of rValue

See Also:
The Kernel-E Assignment Expression

visitCallExpr

public Object visitCallExpr(ENode optOriginal,
                            EExpr recip,
                            String verb,
                            EExpr[] args)
Enabled: recip verb "(" args*, ")".

Eval left to right, then synchronously call the verb method of the value of recip with the values of the args.

See Also:
The Kernel-E Call Expression

visitDefineExpr

public Object visitDefineExpr(ENode optOriginal,
                              Pattern patt,
                              EExpr rValue)
Enabled: "def" patt ":=" rValue.

Match patt against the value of rValue. Neither patt nor rValue may use any variables defined by the other. This allows their scopes to be order independent.

See Also:
The Kernel-E Define Expression

visitEscapeExpr

public Object visitEscapeExpr(ENode optOriginal,
                              Pattern hatch,
                              EExpr body)
Enabled: "escape" hatch "{" body "}".

Bind hatch to an escape hatch. If the escape hatch's run/1 is called during the execution of body, the escape expression will be exited early, and the run argument will be the value. If run/0 is called, it's as if run(null) were called.

See Also:
The Kernel-E Escape Expression

visitHideExpr

public Object visitHideExpr(ENode optOriginal,
                            EExpr body)
Enabled: "{" body "}".

Evaluate body, but hide all variable names it defines from the surrounding scope.

See Also:
The Kernel-E Hide Expression

visitIfExpr

public Object visitIfExpr(ENode optOriginal,
                          EExpr test,
                          EExpr then,
                          EExpr els)
Enabled: "if" "("test")" "{" then "}" "else" "{" els "}".

Evaluate test to a boolean. If true, the value is the evaluation of then. Else the value is the evaluation of els.

See Also:
The Kernel-E If Expression

visitLiteralExpr

public Object visitLiteralExpr(ENode optOriginal,
                               Object value)
Enabled: value.

This value is the value of the expression.

See Also:
The Kernel-E Literal Expression

visitMatchBindExpr

public Object visitMatchBindExpr(ENode optOriginal,
                                 EExpr specimen,
                                 Pattern patt)
Enabled: specimen "=~" patt.

Match patt against the value of specimen. Say whether it matches.

See Also:
The Kernel-E Match-Bind Expression

visitNounExpr

public Object visitNounExpr(ENode optOriginal,
                            String varName)
Enabled: varName.

The result of a getValue() on the slot named by this varName.

See Also:
The Kernel-E Noun Expression

visitObjectExpr

public Object visitObjectExpr(ENode optOriginal,
                              String docComment,
                              String optFQN,
                              EExpr[] auditors,
                              EScript eScript)
Enabled: "##" synopsys "def" string-literal ("implements" auditors)? (eScript | matcher)

Define an object that responds to messages according to eScript

Each auditor must be bound to a "global" final variable, ie, a read-only variable in the incoming scope for evaluating the overall expression. The value of this variable is read once and its value is asked to audit the parse tree of the ObjectExpr it is being asked to audit. Only if all auditors approve of all the audited subtrees in the expression as a whole does execution continue.

At runtime, given an auditor and an instance of an ObjectExpr audited by that auditor, it must be possible to unspoofably ask that auditor whether this is such an instance.

XXX currently, when we a matcher should be provided, an eScript with a 'null' for optMethods is provided instead.

See Also:
The Kernel-E Object Expression

visitQuasiLiteralExpr

public Object visitQuasiLiteralExpr(ENode optOriginal,
                                    int index)
Enabled: "$" "{" index "}".

A placeholder in a quasi-parseTree to be filled in, by substitution, with a real expression. This is not part of Kernel-E.


visitQuasiPatternExpr

public Object visitQuasiPatternExpr(ENode optOriginal,
                                    int index)
Enabled: "@" "{" index "}".

A placeholder in a quasi-pattern-parseTree to capture a corresponding expression in a specimen parseTree, and say where to put it in the binding vector. This is not part of Kernel-E.


visitScopeExpr

public Object visitScopeExpr(ENode optOriginal)
Enabled: "meta" "scope".

Reifies the current runtime scope as a runtime scope object. This should not be part of Kernel-E, but currently is.


visitSendExpr

public Object visitSendExpr(ENode optOriginal,
                            EExpr recip,
                            String verb,
                            EExpr[] args)
Enabled: recip "<-" verb "(" args*, ")".

Like call, but asks that recip do the operation eventually, in its own turn.

See Also:
The Kernel-E Send Expression

visitSeqExpr

public Object visitSeqExpr(ENode optOriginal,
                           EExpr[] subs)
Enabled: first "\n" second.

Do first, then evaluate to the result of second.

See Also:
The Kernel-E Sequence Expression

visitSlotExpr

public Object visitSlotExpr(ENode optOriginal,
                            AtomicExpr noun)
Enabled: "&" varName.

The value is the slot named by varName.


visitCatchExpr

public Object visitCatchExpr(ENode optOriginal,
                             EExpr attempt,
                             Pattern patt,
                             EExpr catcher)
Enabled: "try" "{" attempt "}" "catch" patt "{" catcher "}".

Evaluate attempt. If it completes successfully, then its value is the value of the catch-expression. If it throws an exception, match it against patt. If it succeeds, evaluate to the evaluation of catcher. Otherwise rethrow the exception.

See Also:
The Kernel-E Try-Catch Expression

visitFinallyExpr

public Object visitFinallyExpr(ENode optOriginal,
                               EExpr attempt,
                               EExpr unwinder)
Enabled: "try" "{" attempt "}" "finally" "{" unwinder "}".

Evaluate attempt. On the way out, whether by successful completion or abrupt termination (throw or escape), in all cases evaluate the unwinder before leaving. If attempt succeeds, then the value of the finally-expression is the value of attempt.

See Also:
The Kernel-E Try-Finally Expression

visitFinalPattern

public Object visitFinalPattern(ENode optOriginal,
                                String varName,
                                EExpr valueGuardExpr)
Enabled: varName (":" valueGuardExpr)?.

Ask the value of valueGuardExpr to coerce(specimen, XXX), and define the the value of varName to be the result.

See Also:
The Kernel-E Final Pattern

visitVarPattern

public Object visitVarPattern(ENode optOriginal,
                              String varName,
                              EExpr slotGuardExpr)
Enabled: var varName (":" slotGuardExpr)?.

Ask the value of slotGuardExpr to makeSlot(specimen, XXX), and define the result to be the slot named by varName.

See Also:
The Kernel-E Var Pattern

visitListPattern

public Object visitListPattern(ENode optOriginal,
                               Pattern[] subs)
Enabled: "["pattern*, "]".

Is the specimen a list exactly this long, and do each of the elements match the corresponding sub-pattern?

See Also:
The Kernel-E Tuple Pattern

visitCdrPattern

public Object visitCdrPattern(ENode optOriginal,
                              ListPattern subs,
                              Pattern rest)
Enabled: listPattern "+" pattern

Is the specimen a list at least as long, and does each of the first N elements match the listPattern's sub-pattern? Does the right hand pattern match a list of the remaining elements?

See Also:
The Kernel-E Tuple Pattern

visitIgnorePattern

public Object visitIgnorePattern(ENode optOriginal)
Enabled: "_".

Matches anything, binds nothing.

See Also:
The Kernel-E Ignore Pattern

visitSuchThatPattern

public Object visitSuchThatPattern(ENode optOriginal,
                                   Pattern patt,
                                   EExpr test)
Enabled: patt "?" test.

Does patt match the specimen? And does test evaluate to true?

See Also:
The Kernel-E Such-That Pattern

visitQuasiLiteralPatt

public Object visitQuasiLiteralPatt(ENode optOriginal,
                                    int index)
Enabled: "$" "{" index "}".

A placeholder in a quasi-parseTree to be filled in, by substitution, with a real pattern. Not part of Kernel-E.


visitQuasiPatternPatt

public Object visitQuasiPatternPatt(ENode optOriginal,
                                    int index)
Enabled: "@" "{" index "}".

A placeholder in a quasi-pattern-parseTree to capture a corresponding pattern in a specimen parseTree, and say where to put it in the binding vector. Not part of Kernel-E.


visitEScript

public Object visitEScript(ENode optOriginal,
                           EMethodNode[] optMethods,
                           Matcher optMatcher)
Enabled: "{" methods* matcher? "}"? XXX currently, when a matcher should have been provided to visitObjectExpr, instead an eScript is provided whose optMethods is null. This breaks the XML translation, since the XML encoding cannot distinguish between no method and an empty list of methods.

See Also:
The Kernel-E Script Node

visitEMethod

public Object visitEMethod(ENode optOriginal,
                           String docComment,
                           String verb,
                           Pattern[] patterns,
                           EExpr returnGuard,
                           EExpr body)
Enabled: "##" docComment
"to" verb "(" patterns*, ")" ":" returnGuard "{" body "}".

Defines a method for verb and a number of arguments matching the number of patterns. When the containing object is sent such a message, the arguments are matched against the patterns, and then the body is evaluated. They value of body as coerced by returnGuard is finally revealed.

See Also:
The Kernel-E Method Node

visitMatcher

public Object visitMatcher(ENode optOriginal,
                           Pattern pattern,
                           EExpr body)
Enabled: "match" pattern "{" body "}".

When the incoming message doesn't fit any of the methods, then a pair of the verb and the arguments is matched against patt, then body is evaluated, and it value revealed.

See Also:
The Kernel-E Matcher Node


comments?