Package edu.mit.eecs.parserlib
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 Summary
Modifier and Type Method Description static <NT extends Enum<NT>>
voidshowInBrowser(ParseTree<NT> parseTree)
Tries to show a visualization of a parse tree in your web browser.static <NT extends Enum<NT>>
voidwriteToFile(ParseTree<NT> parseTree, String filename)
Generate an HTML visualization of the parse tree and write it to a file.
-
Method Details
-
showInBrowser
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 IOExceptionGenerate 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 visualizefilename
- output file. Advisable to give it ".html" extension, though not required.- Throws:
IOException
- if unable to write the file.
-