step9
Class bdis

java.lang.Object
  extended by step9.i
      extended by step9.bi
          extended by step9.bdis
All Implemented Interfaces:
Visitor

public class bdis
extends bi

rewrites Node trees as typed trees. Infrastructure and support for bi.BooleanT, bdis.DoubleT, i.IntegerT and bdis.StringT. Naming convention: the suffix T indicates a type.


Nested Class Summary
static class bdis.DAdd
          add two bdis.DoubleT trees.
static class bdis.DDiv
          divide two bdis.DoubleT trees.
static class bdis.DEq
          equal of two bdis.DoubleT trees.
static class bdis.DGe
          greater-equal of two bdis.DoubleT trees.
static class bdis.DGt
          greater-then of two bdis.DoubleT trees.
static class bdis.DLe
          less-equal of two bdis.DoubleT trees.
static class bdis.DLt
          less-then of two bdis.DoubleT trees.
static class bdis.DMinus
          sign-change an bdis.DoubleT tree.
static class bdis.DMul
          multiply two bdis.DoubleT trees.
static class bdis.DNe
          not-equal of two bdis.DoubleT trees.
static class bdis.DoubleT
          base class for double operations, itself used to type a Double leaf.
static class bdis.DPrint
          print a bdis.DoubleT object.
static class bdis.DSub
          subtract two bdis.DoubleT trees.
static class bdis.I2D
          convert i.IntegerT to bdis.DoubleT.
static class bdis.SAdd
          concatenate two bdis.StringT trees.
static class bdis.SEq
          equal of two bdis.StringT trees.
static class bdis.SGe
          greater-equal of two bdis.StringT trees.
static class bdis.SGt
          greater-then of two bdis.StringT trees.
static class bdis.SLe
          less-equal of two bdis.StringT trees.
static class bdis.SLt
          less-then of two bdis.StringT trees.
static class bdis.SNe
          not-equal of two bdis.StringT trees.
static class bdis.SPrint
          print a bdis.StringT object.
static class bdis.StringT
          base class for string operations, itself used to type a String leaf.
 
Nested classes/interfaces inherited from class step9.bi
bi.BAnd, bi.BAndIf, bi.BEq, bi.BNe, bi.BNot, bi.BooleanT, bi.BOr, bi.BOrIf, bi.BPrint, bi.BXor, bi.IEq, bi.IGe, bi.IGt, bi.ILe, bi.ILt, bi.INe
 
Nested classes/interfaces inherited from class step9.i
i.IAdd, i.IAnd, i.IDiv, i.ILsh, i.IMinus, i.IMod, i.IMul, i.INeg, i.IntegerT, i.IOr, i.IPrint, i.IRsh, i.ISub, i.IXor, i.T
 
Field Summary
protected  HashMap _rules
          maps class to array of Rule.
protected  PrintStream out
          print action stream.
 
Constructor Summary
bdis()
           
 
Method Summary
 Object DAdd(ArrayList sub)
          factory method: add two bdis.DoubleT trees.
 Object DDiv(ArrayList sub)
          factory method: divide two bdis.DoubleT trees.
 Object DEq(ArrayList sub)
          factory method: equal of two bdis.DoubleT trees.
 Object DGe(ArrayList sub)
          factory method: greater-equal of two bdis.DoubleT trees.
 Object DGt(ArrayList sub)
          factory method: greater-then of two bdis.DoubleT trees.
 Object DLe(ArrayList sub)
          factory method: less-equal of two bdis.DoubleT trees.
 Object DLt(ArrayList sub)
          factory method: less-then of two bdis.DoubleT trees.
 Object DMinus(ArrayList sub)
          factory method: sign-change an bdis.DoubleT tree.
 Object DMul(ArrayList sub)
          factory method: multiply two bdis.DoubleT trees.
 Object DNe(ArrayList sub)
          factory method: not-equal of two bdis.DoubleT trees.
 bdis.DoubleT DoubleT(Double d)
          factory method: type a Double leaf.
 Object DPrint(bdis.DoubleT sub)
          factory method: print a bdis.DoubleT object.
 Object DSub(ArrayList sub)
          factory method: subtract two bdis.DoubleT trees.
 Object I2D(i.IntegerT sub)
          factory method: convert i.IntegerT to bdis.DoubleT.
static void main(String[] args)
          type lines with mixed mode expressions.
protected  PrintStream out()
          returns print action stream.
 Object SAdd(ArrayList sub)
          factory method: concatenate two bdis.StringT trees.
 Object SEq(ArrayList sub)
          factory method: equal of two bdis.StringT trees.
 Object SGe(ArrayList sub)
          factory method: greater-equal of two bdis.StringT trees.
 Object SGt(ArrayList sub)
          factory method: greater-then of two bdis.StringT trees.
 Object SLe(ArrayList sub)
          factory method: less-equal of two bdis.StringT trees.
 Object SLt(ArrayList sub)
          factory method: less-then of two bdis.StringT trees.
 Object SNe(ArrayList sub)
          factory method: not-equal of two bdis.StringT trees.
 Object SPrint(bdis.StringT sub)
          factory method: print a bdis.StringT object.
 bdis.StringT StringT(String s)
          factory method: type a String leaf.
 Object visit(int _action, Object _object)
          visits an object.
 Object visit(Object object)
          visits an object.
 Object visit0(Object object)
          visits an object, ignoring possible descendants.
 
Methods inherited from class step9.bi
BAnd, BAndIf, BEq, BNe, BNot, BooleanT, BOr, BOrIf, BPrint, BXor, IEq, IGe, IGt, ILe, ILt, INe
 
Methods inherited from class step9.i
classname, IAdd, IAnd, IDiv, ILsh, IMinus, IMod, IMul, INeg, IntegerT, IOr, IPrint, IRsh, ISub, IXor, prefix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

protected transient PrintStream out
print action stream. Can be replaced to reroute output. BUG: should be a self-flushing PrintWriter.


_rules

protected final HashMap _rules
maps class to array of Rule.

Constructor Detail

bdis

public bdis()
Method Detail

out

protected PrintStream out()
returns print action stream. Defaults to System.out.

Overrides:
out in class bi

visit

public Object visit(Object object)
             throws Exception
visits an object. This is a facade for the class search.

Specified by:
visit in interface Visitor
Overrides:
visit in class bi
Parameters:
object - to be visited, not null.
Returns:
result of action.
Throws:
NoRuleException - if no rule can be found.
Exception
See Also:
Rule.visit(jag.Visitor, java.util.HashMap, java.lang.Object, int, java.util.List)

visit0

public Object visit0(Object object)
              throws Exception
visits an object, ignoring possible descendants. This is a facade for the class search with degree zero.

Specified by:
visit0 in interface Visitor
Overrides:
visit0 in class bi
Parameters:
object - to be visited, not null.
Returns:
result of action.
Throws:
NoRuleException - if no rule can be found.
Exception
See Also:
Rule.visit(jag.Visitor, java.util.HashMap, java.lang.Object, int, java.util.List)

visit

public Object visit(int _action,
                    Object _object)
             throws Exception
visits an object.

Specified by:
visit in interface Visitor
Overrides:
visit in class bi
Parameters:
_action - index.
_object - to be visited, not null.
Returns:
result of action.
Throws:
NoRuleException - if no rule can be found.
Exception

DoubleT

public bdis.DoubleT DoubleT(Double d)
factory method: type a Double leaf.


StringT

public bdis.StringT StringT(String s)
factory method: type a String leaf.


main

public static void main(String[] args)
                 throws Exception
type lines with mixed mode expressions.

Throws:
Exception

DPrint

public Object DPrint(bdis.DoubleT sub)
factory method: print a bdis.DoubleT object.


DAdd

public Object DAdd(ArrayList sub)
factory method: add two bdis.DoubleT trees.


DSub

public Object DSub(ArrayList sub)
factory method: subtract two bdis.DoubleT trees.


DMul

public Object DMul(ArrayList sub)
factory method: multiply two bdis.DoubleT trees.


DDiv

public Object DDiv(ArrayList sub)
factory method: divide two bdis.DoubleT trees.


DMinus

public Object DMinus(ArrayList sub)
factory method: sign-change an bdis.DoubleT tree.


I2D

public Object I2D(i.IntegerT sub)
factory method: convert i.IntegerT to bdis.DoubleT.


DLt

public Object DLt(ArrayList sub)
factory method: less-then of two bdis.DoubleT trees.


DLe

public Object DLe(ArrayList sub)
factory method: less-equal of two bdis.DoubleT trees.


DGt

public Object DGt(ArrayList sub)
factory method: greater-then of two bdis.DoubleT trees.


DGe

public Object DGe(ArrayList sub)
factory method: greater-equal of two bdis.DoubleT trees.


DEq

public Object DEq(ArrayList sub)
factory method: equal of two bdis.DoubleT trees.


DNe

public Object DNe(ArrayList sub)
factory method: not-equal of two bdis.DoubleT trees.


SPrint

public Object SPrint(bdis.StringT sub)
factory method: print a bdis.StringT object.


SAdd

public Object SAdd(ArrayList sub)
factory method: concatenate two bdis.StringT trees.


SLt

public Object SLt(ArrayList sub)
factory method: less-then of two bdis.StringT trees.


SLe

public Object SLe(ArrayList sub)
factory method: less-equal of two bdis.StringT trees.


SGt

public Object SGt(ArrayList sub)
factory method: greater-then of two bdis.StringT trees.


SGe

public Object SGe(ArrayList sub)
factory method: greater-equal of two bdis.StringT trees.


SEq

public Object SEq(ArrayList sub)
factory method: equal of two bdis.StringT trees.


SNe

public Object SNe(ArrayList sub)
factory method: not-equal of two bdis.StringT trees.