Search code examples
rascal

Pretty printing AST in Rascal


I am trying to pretty print an AST generated from

createAstFromFile(|cwd:///Java/Hello.java|,true);

Have I just missed how to do this in the documentation?


Solution

  • If you mean unparsing an AST (getting the Java code back) you will have to write something yourself.

    If you however mean printing the AST structure nicely indented, we have iprintln exactly for this purpose.

    Also, for large ASTs, the REPL might not like it that much, checkout our (as pf yet) undocumented Fast print functions in util::FastPrint. The fiprintln prints to the rascal output window, which is a lot faster.