Class Visualizer

java.lang.Object
edu.mit.eecs.parserlib.Visualizer

public class Visualizer
extends Object
Support for visualizing a parse tree in a web browser, for debugging purposes.
Author:
6.005/6.031 course staff
  • Method Details

    • showInBrowser

      public static <NT extends Enum<NT>> void showInBrowser​(ParseTree<NT> parseTree)
      Tries to show a visualization of a parse tree in your web browser. If you are not connected to the internet, or if the method cannot launch the browser, it will print a very long URL to your console which you can then copy to your browser to see the visualization.
      Type Parameters:
      NT - the enumeration of symbols in the parse tree's grammar
      Parameters:
      parseTree - tree to visualize
    • writeToFile

      public static <NT extends Enum<NT>> void writeToFile​(ParseTree<NT> parseTree, String filename) throws IOException
      Generate an HTML visualization of the parse tree and write it to a file.
      Type Parameters:
      NT - the enumeration of symbols in the parse tree's grammar
      Parameters:
      parseTree - tree to visualize
      filename - output file. Advisable to give it ".html" extension, though not required.
      Throws:
      IOException - if unable to write the file.