summaryrefslogtreecommitdiff
path: root/test/pending/run/reify_csv.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2011-12-05 00:05:57 +0100
committerEugene Burmako <xeno.by@gmail.com>2011-12-05 00:05:57 +0100
commit7193d21a9be25bf8a705492493971f3267687098 (patch)
tree0f03cd92cc5898cb7c809019e475005f3bc3603a /test/pending/run/reify_csv.scala
parent3e9e4ecf360e6eda5c26f798abfcb9bb882cf772 (diff)
downloadscala-7193d21a9be25bf8a705492493971f3267687098.tar.gz
scala-7193d21a9be25bf8a705492493971f3267687098.tar.bz2
scala-7193d21a9be25bf8a705492493971f3267687098.zip
Test pack for various flavors of reflection.
Diffstat (limited to 'test/pending/run/reify_csv.scala')
-rw-r--r--test/pending/run/reify_csv.scala42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/pending/run/reify_csv.scala b/test/pending/run/reify_csv.scala
new file mode 100644
index 0000000000..a05a3b55d4
--- /dev/null
+++ b/test/pending/run/reify_csv.scala
@@ -0,0 +1,42 @@
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import reflect.runtime.Mirror.ToolBox
+
+object Test extends App {
+ val csv = """
+ | phase name; id; description
+ | parser; 1; parse source into ASTs, perform simple desugaring
+ | namer; 2; resolve names, attach symbols to named trees
+ |packageobjects; 3; load package objects
+ | typer; 4; the meat and potatoes: type the trees
+ |superaccessors; 5; add super accessors in traits and nested classes
+ | pickler; 6; serialize symbol tables
+ | refchecks; 7; reference/override checking, translate nested objects
+ | selectiveanf; 8;
+ | liftcode; 9; reify trees""".stripMargin.split("\n").map{_.trim()}.drop(1).toList
+
+ val fields = csv.head.split(";").map{_.trim()}.toList
+ println(fields)
+
+ val code = scala.reflect.Code.lift({
+ object Csv {
+ case class record(`phase name`: String, id: String, description: String)
+
+ object record {
+ def parse(lines: List[String]) = {
+ lines drop(1) map { line => line.split(";", -1).toList match {
+ case phase$whitespace$name :: id :: description :: _ => record(phase$whitespace$name.trim(), id.trim(), description.trim())
+ case _ => throw new Exception("format error")
+ }}
+ }
+ }
+ }
+
+ Csv.record.parse(csv) foreach println
+ })
+
+ val reporter = new ConsoleReporter(new Settings)
+ val toolbox = new ToolBox(reporter)
+ val ttree = toolbox.typeCheck(code.tree)
+ toolbox.runExpr(ttree)
+}