step9
Class bi

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

public class bi
extends i

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


Nested Class Summary
static class bi.BAnd
          and of two bi.BooleanT trees.
static class bi.BAndIf
          and-if of two bi.BooleanT trees.
static class bi.BEq
          equal of two bi.BooleanT trees.
static class bi.BNe
          not-equal of two bi.BooleanT trees.
static class bi.BNot
          negate a bi.BooleanT tree.
static class bi.BooleanT
          base class for boolean operations, itself used to type an Boolean leaf.
static class bi.BOr
          or of two bi.BooleanT trees.
static class bi.BOrIf
          or-if of two bi.BooleanT trees.
static class bi.BPrint
          print a bi.BooleanT object.
static class bi.BXor
          xor of two bi.BooleanT trees.
static class bi.IEq
          equal of two i.IntegerT trees.
static class bi.IGe
          greater-equal of two i.IntegerT trees.
static class bi.IGt
          greater-then of two i.IntegerT trees.
static class bi.ILe
          less-equal of two i.IntegerT trees.
static class bi.ILt
          less-then of two i.IntegerT trees.
static class bi.INe
          not-equal of two i.IntegerT trees.
 
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
bi()
           
 
Method Summary
 Object BAnd(ArrayList sub)
          factory method: and of two bi.BooleanT trees.
 Object BAndIf(ArrayList sub)
          factory method: and-if of two bi.BooleanT trees.
 Object BEq(ArrayList sub)
          factory method: equal of two bi.BooleanT trees.
 Object BNe(ArrayList sub)
          factory method: not-equal of two bi.BooleanT trees.
 Object BNot(ArrayList sub)
          factory method: negate a bi.BooleanT tree.
 bi.BooleanT BooleanT(Boolean b)
          factory method: type a Boolean leaf.
 Object BOr(ArrayList sub)
          factory method: or of two bi.BooleanT trees.
 Object BOrIf(ArrayList sub)
          factory method: or-if of two bi.BooleanT trees.
 Object BPrint(bi.BooleanT sub)
          factory method: print a bi.BooleanT object.
 Object BXor(ArrayList sub)
          factory method: xor of two bi.BooleanT trees.
 Object IEq(ArrayList sub)
          factory method: equal of two i.IntegerT trees.
 Object IGe(ArrayList sub)
          factory method: greater-equal of two i.IntegerT trees.
 Object IGt(ArrayList sub)
          factory method: greater-then of two i.IntegerT trees.
 Object ILe(ArrayList sub)
          factory method: less-equal of two i.IntegerT trees.
 Object ILt(ArrayList sub)
          factory method: less-then of two i.IntegerT trees.
 Object INe(ArrayList sub)
          factory method: not-equal of two i.IntegerT trees.
static void main(String[] args)
          type lines with integer and boolean expressions.
protected  PrintStream out()
          returns print action stream.
 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.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

bi

public bi()
Method Detail

out

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

Overrides:
out in class i

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 i
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 i
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 i
Parameters:
_action - index.
_object - to be visited, not null.
Returns:
result of action.
Throws:
NoRuleException - if no rule can be found.
Exception

BooleanT

public bi.BooleanT BooleanT(Boolean b)
factory method: type a Boolean leaf.


main

public static void main(String[] args)
                 throws Exception
type lines with integer and boolean expressions.

Throws:
Exception

BPrint

public Object BPrint(bi.BooleanT sub)
factory method: print a bi.BooleanT object.


BOrIf

public Object BOrIf(ArrayList sub)
factory method: or-if of two bi.BooleanT trees.


BAndIf

public Object BAndIf(ArrayList sub)
factory method: and-if of two bi.BooleanT trees.


BOr

public Object BOr(ArrayList sub)
factory method: or of two bi.BooleanT trees.


BXor

public Object BXor(ArrayList sub)
factory method: xor of two bi.BooleanT trees.


BAnd

public Object BAnd(ArrayList sub)
factory method: and of two bi.BooleanT trees.


BEq

public Object BEq(ArrayList sub)
factory method: equal of two bi.BooleanT trees.


BNe

public Object BNe(ArrayList sub)
factory method: not-equal of two bi.BooleanT trees.


BNot

public Object BNot(ArrayList sub)
factory method: negate a bi.BooleanT tree.


ILt

public Object ILt(ArrayList sub)
factory method: less-then of two i.IntegerT trees.


ILe

public Object ILe(ArrayList sub)
factory method: less-equal of two i.IntegerT trees.


IGt

public Object IGt(ArrayList sub)
factory method: greater-then of two i.IntegerT trees.


IGe

public Object IGe(ArrayList sub)
factory method: greater-equal of two i.IntegerT trees.


IEq

public Object IEq(ArrayList sub)
factory method: equal of two i.IntegerT trees.


INe

public Object INe(ArrayList sub)
factory method: not-equal of two i.IntegerT trees.