|
Scala example source code file (treePrint.scala)
The Scala treePrint.scala source code/** Testing compact tree printers. */ object Test { import scala.tools.nsc._ import interpreter._ 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 intp = new IMain(settings, new PrintWriter(new NullOutputStream)) val power = Power(intp) intp.interpret("""def initialize = "Have to interpret something or we get errors." """) power trees code foreach println } } Other Scala examples (source code examples)Here is a short list of links related to this Scala treePrint.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.