예제 #1
0
 public static void main(String[] args) {
   try {
     Node root = new MiniRAParser(System.in).Goal();
     // System.out.println("Program parsed successfully");
     Object a = root.accept(new GJDepthFirst(), null);
     // root.accept(new GJNoArgu(a));
   } catch (ParseException e) {
     System.out.println(e.toString());
   }
 }
예제 #2
0
  public static void main(String[] args) {
    try {
      Node root = new MiniJavaParser(System.in).Goal();

      HashMap<String, String> s =
          (HashMap<String, String>)
              root.accept(new GJNoArguDepthFirst()); // Your assignment part is invoked here.
      root.accept(new GJDepthFirst<Object, Object>(), s);
      System.out.println("Program type checked successfully");

    } catch (ParseException e) {
      System.out.println(e.toString());
    }
  }
예제 #3
0
  public static void main(String[] args) {

    try {
      // File file = new File("C:\\tiger2\\testcases\\BinarySearch.java");
      // File file = new File("C:\\tiger2\\testcases\\BinaryTree.java");
      // File file = new File("C:\\tiger2\\testcases\\BubbleSort.java");
      File file = new File("C:\\tiger2\\testcases\\Factorial.java");
      // File file = new File("C:\\tiger2\\testcases\\LinearSearch.java");
      // File file = new File("C:\\tiger2\\testcases\\LinkedList.java");
      // File file = new File("C:\\tiger2\\testcases\\QuickSort.java");
      // File file = new File("C:\\tiger2\\testcases\\Test1.java");
      // File file = new File("C:\\tiger2\\testcases\\TreeVisitor.java");
      FileInputStream stream = new FileInputStream(file);
      Program root = new MiniJavaParser(stream).Goal();

      // Print the original source code from the abstract syntax tree:
      root.accept(new PrettyPrintVisitor());
      // root.accept(new ASTPrintVisitor());

      // Print the abstract syntax tree:
      // root.accept(new ASTPrintVisitor());	// Should this have been called "UglyPrintVisitor"? :)

    } catch (ParseException e) {
      System.out.println(e.toString());
    } catch (FileNotFoundException fnfe) {
      System.out.println("File not found!");
    }

    /*try {
      //File file = new File("C:\\tiger2\\testcases\\Factorial.java");
      File file = new File("C:\\tiger2\\testcases\\BubbleSort.java");
      //File file = new File("C:\\tiger2\\testcases\\Test1.java");
      FileInputStream stream = new FileInputStream(file);
      MiniJavaParser parser = new MiniJavaParser(stream);
      parser.Goal();
      System.out.println("Parse succeeded.");
    }
    catch (FileNotFoundException fnfe)
    {
      System.out.println("File not found!");
    }
    catch (ParseException e) {
      System.out.println("Parser Error : \n"+ e.toString());
    }*/
  }