step7
Class eval

java.lang.Object
  extended by step7.eval
All Implemented Interfaces:
Visitor

public class eval
extends Object
implements Visitor

evaluate expr tree with integer arithmetic.


Field Summary
protected  HashMap _rules
          maps class to array of Rule.
protected  PrintStream out
          print action stream.
 
Constructor Summary
eval()
           
 
Method Summary
static void main(String[] args)
          read an expression from standard input and output it's value.
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 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

eval

public eval()
Method Detail

out

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


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

main

public static void main(String[] args)
                 throws Exception
read an expression from standard input and output it's value.

Throws:
Exception