import java.io.*; import java_cup.runtime.*; /**** * * Test program for CSC 330 Assignment 4 Pascal example. See comment for * EJayInterpreterTestNoFuncs for further information. The reason this acts * like the NoFuncs version of the EJay tester is that a Pascal program has no * distinguished main method, but rather starts by executing the statements * body of the whole program. * */ public class PascalInterpreterTest { /** * See the class comment for documentation. */ public static void main(String[] args) { TreeNode2 tree; SymbolTable symtab; try { PascalParser parser = new PascalParser( new PascalLexer(new FileReader(args[0]))); parser.initSymbolTable(500); tree = (TreeNode2) parser.parse().value; System.out.println(tree); System.out.println(); System.out.println(symtab = parser.getSymbolTable()); PascalInterpreter interp = new PascalInterpreter(symtab.memorySize, 10000); interp.eval(tree.child2, symtab); interp.dumpMemory(); } catch (Exception e) { System.out.println("Exception "); e.printStackTrace(); } } }