Skip to content

Instantly share code, notes, and snippets.

@retronym
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retronym/32b02cc453b26dd9314d to your computer and use it in GitHub Desktop.
Save retronym/32b02cc453b26dd9314d to your computer and use it in GitHub Desktop.
% printf "val x = 1\nimport x.toInt\n x + toInt\n" | scala -Xprint:parser
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val x = 1
[[syntax trees at end of parser]] // <init>
package <empty> {
class $repl_$init extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
<empty>
}
}
[[syntax trees at end of parser]] // <console>
package $line1 {
object $eval extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
var value: scala.tools.nsc.interpreter.IMain = _;
def set(x: Any) = value = x.asInstanceOf[scala.tools.nsc.interpreter.IMain]
}
}
[[syntax trees at end of parser]] // <console>
package $line2 {
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val $intp = $line1.$eval.value
}
}
}
}
[[syntax trees at end of parser]] // <console>
package $line2 {
object $eval extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
lazy val $result = $line2.$read.$iw.$iw.$intp;
lazy val $print: String = {
$line2.$read.$iw.$iw;
""
}
}
}
[[syntax trees at end of parser]] // <console>
package $line3 {
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val x = 1
}
}
}
}
[[syntax trees at end of parser]] // <console>
package $line3 {
object $eval extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
lazy val $result = $line3.$read.$iw.$iw.x;
lazy val $print: String = {
$line3.$read.$iw.$iw;
"".$plus("x: Int = ").$plus(scala.runtime.ScalaRunTime.replStringOf($line3.$read.$iw.$iw.x, 1000))
}
}
}
x: Int = 1
scala> import x.toInt
[[syntax trees at end of parser]] // <console>
package $line4 {
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
import $line3.$read.$iw.$iw.x;
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
import x.toInt
}
}
}
}
[[syntax trees at end of parser]] // <console>
package $line4 {
object $eval extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
lazy val $print: String = {
$line4.$read.$iw.$iw;
"".$plus("import x.toInt").$plus("\n")
}
}
}
import x.toInt
[[syntax trees at end of parser]] // <console>
package $line7 {
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
import $line3.$read.$iw.$iw.x;
import x.toInt;
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
def $ires2 = x
}
}
}
}
[[syntax trees at end of parser]] // <console>
package $line7 {
object $eval extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
lazy val $result = $line7.$read.$iw.$iw.$ires2;
lazy val $print: String = {
$line7.$read.$iw.$iw;
"".$plus("$ires2: Int\n")
}
}
}
[[syntax trees at end of parser]] // <console>
package $line6 {
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
import $line3.$read.$iw.$iw.x;
import x.toInt;
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
def $ires1 = x
}
}
}
}
[[syntax trees at end of parser]] // <console>
package $line6 {
object $eval extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
lazy val $result = $line6.$read.$iw.$iw.$ires1;
lazy val $print: String = {
$line6.$read.$iw.$iw;
"".$plus("$ires1: Int\n")
}
}
}
[[syntax trees at end of parser]] // <console>
package $line5 {
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
import $line3.$read.$iw.$iw.x;
import x.toInt;
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
def $ires0 = x
}
}
}
}
[[syntax trees at end of parser]] // <console>
package $line5 {
object $eval extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
lazy val $result = $line5.$read.$iw.$iw.$ires0;
lazy val $print: String = {
$line5.$read.$iw.$iw;
"".$plus("$ires0: Int\n")
}
}
}
scala> x + toInt
[[syntax trees at end of parser]] // <console>
package $line8 {
object $read extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
import $line3.$read.$iw.$iw.x;
import x.toInt;
object $iw extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
val res0 = x.$plus(toInt)
}
}
}
}
[[syntax trees at end of parser]] // <console>
package $line8 {
object $eval extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
lazy val $result = $line8.$read.$iw.$iw.res0;
lazy val $print: String = {
$line8.$read.$iw.$iw;
"".$plus("res0: Int = ").$plus(scala.runtime.ScalaRunTime.replStringOf($line8.$read.$iw.$iw.res0, 1000))
}
}
}
res0: Int = 2
scala> :quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment