--- a/misc/smeta.sc Fri Aug 28 16:54:49 2020 +0100
+++ b/misc/smeta.sc Sat Aug 29 16:05:59 2020 +0100
@@ -1,6 +1,30 @@
-import $ivy.`org.scalameta::scalameta:4.3.21`
+#!/usr/bin/env amm
+
+import $ivy.`org.scalameta::scalameta:4.3.20`
import scala.meta._
+import ammonite.ops._
-println("a + b".parse[Stat].get.structure)
-
\ No newline at end of file
+@main
+def main(s: String) = {
+ val file = read(pwd / RelPath(s))
+ val tree = file.parse[Source].get
+ val vrs = tree.collect {
+ case Defn.Var(_, x, _, _) => x.toString
+ case Term.Return(t) => t.toString
+ }
+ println(vrs.mkString("\n"))
+}
+
+
+/*
+q"val x = 2".traverse {
+ case node =>
+ println(s"${node.productPrefix}: $node")
+}
+*/
+
+//https://scalameta.org/docs/trees/guide.html#custom-traversals
+
+
+//https://geirsson.com/post/2016/02/scalameta/
\ No newline at end of file