import ilog.language.syntax.GenericParser;

public class PartialCalculator
{
  public static void main (String args[])
    {
      try
        {
          CalculatorTokenizer t;

          t = new CalculatorTokenizer("");

          try
            {
              CalculatorParser p = new CalculatorParser(t);

              String input;

              p.parseTreeType = p.COMPACT_TREE;
//            p.toggleTrace();
              
              System.out.println("\n---------------------------------------------\n");

              p.parseExpression(input="1+2");
              System.out.println("\nvalue() of "+input+" is "+p.currentNode().nvalue());
              System.out.println("\nPARSE TREE:\n");
              p.currentNode().show();

              System.out.println("\n---------------------------------------------\n");

              p.parseDefinition("pi = 22/7");
              System.out.println("\nDefining pi as "+p.currentNode().nvalue());
              System.out.println("\nPARSE TREE:\n");
              p.currentNode().show();

              System.out.println("\n---------------------------------------------\n");
              
              p.parseExpression("2 * pi");
              System.out.println("\nTwice this pi is "+p.currentNode().nvalue());
              System.out.println("\nPARSE TREE:\n");
              p.currentNode().show();

              System.out.println("\n---------------------------------------------\n");
            }
          catch (Exception e)
            {
              System.out.println("*** Parsing error: "+e);
            }
        }
      catch (Exception e)
        {
          System.out.println("*** Tokenizing error: "+e);
        }
    }
}
