summaryrefslogtreecommitdiff
path: root/test/files/run/treePrint.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-01-30 06:30:57 +0000
committerPaul Phillips <paulp@improving.org>2010-01-30 06:30:57 +0000
commitc73ab4525e402cbbc0fd745a34c453520c87564c (patch)
tree9283e20e3edc5b0eb68853ba52a5101474dd2037 /test/files/run/treePrint.scala
parentbb149d1b96015d83e58de5ea9b380550267c4f06 (diff)
downloadscala-c73ab4525e402cbbc0fd745a34c453520c87564c.tar.gz
scala-c73ab4525e402cbbc0fd745a34c453520c87564c.tar.bz2
scala-c73ab4525e402cbbc0fd745a34c453520c87564c.zip
A compact tree printer, for primitives like mys...
A compact tree printer, for primitives like myself who do all their debugging in the console and need extraneous information filtered out. New option: -Ycompact-trees. Supply that in conjunction with -Xprint:all and suddenly the output is a (relative) masterpiece of concision. Review by anyone who is game to review such a thing. Community?
Diffstat (limited to 'test/files/run/treePrint.scala')
-rw-r--r--test/files/run/treePrint.scala40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/files/run/treePrint.scala b/test/files/run/treePrint.scala
new file mode 100644
index 0000000000..ffe9a392d4
--- /dev/null
+++ b/test/files/run/treePrint.scala
@@ -0,0 +1,40 @@
+/** Testing compact tree printers.
+ */
+object Test {
+ import scala.tools.nsc._
+ import java.io.{ OutputStream, BufferedReader, StringReader, PrintWriter, Writer, OutputStreamWriter}
+
+ val code = """
+ def foo = {
+ var q: Boolean = false
+ val x = if (true) {
+ if (true) {
+ if (true) {
+ 5
+ }
+ else if (true) {
+ 5
+ } else {
+ 10
+ }
+ }
+ else 20
+ }
+ else 30
+
+ (x == 5) || !q || true
+ }
+ """
+
+ class NullOutputStream extends OutputStream { def write(b: Int) { } }
+
+ def main(args: Array[String]) {
+ val settings = new Settings
+ settings.classpath.value = System.getProperty("java.class.path")
+ settings.Ycompacttrees.value = true
+
+ val repl = new Interpreter(settings, new PrintWriter(new NullOutputStream))
+ repl.interpret("""def initialize = "Have to interpret something or we get errors." """)
+ println(repl mkTree code)
+ }
+}