public class interpreter {

//   Jay interpreter - does parsing, type checking, and 
//   interpretively executes the abstract syntax.

static StaticTypeCheck S = new StaticTypeCheck();
static Semantics D = new Semantics();
static TypeMap tm = new TypeMap();
static State sigma = new State();   // state of the variables at run time

public static void main(String args[]) {
   TokenStream MyProgram = new TokenStream(args[0]);
   ConcreteSyntax C  = new ConcreteSyntax(MyProgram);

   System.out.println("Begin parsing... " + args[0]);
   Program A = C.program();      // parse and generate abstract syntax tree
   A.display();               // display abstract syntax tree
   
   System.out.println("\nBegin type checking...");
   if (S.V(A)) {                 // if no type errors, then
      System.out.println("No type errors");
      System.out.print ("\n  Type map = ");
      tm = S.typing(A.decpart);  // generate type map from the declarations
      tm.display();              // and display it

      System.out.println("\nBegin interpreting...");
      sigma = D.M(A);               //  interpret program P

      System.out.print ("\nFinal state sigma = ");
      sigma.display();              //  and display results
   }                       
   else System.out.println("Type error");    
}

}

