Skip to content

Instantly share code, notes, and snippets.

@akhileshs
Created May 24, 2016 07:44
Show Gist options
  • Save akhileshs/c721da78b962fadbe6b1a73d20efab81 to your computer and use it in GitHub Desktop.
Save akhileshs/c721da78b962fadbe6b1a73d20efab81 to your computer and use it in GitHub Desktop.
scala> "{ /* hello */ def foo(bar: Int) = bar }".parse[Term].get
res0: scala.meta.Term = { /* hello */ def foo(bar: Int) = bar }
scala> res0 transform { case q"bar" => q"baz" }
x.origin: Parsed(Input.String("{ /* hello */ def foo(bar: Int) = bar }"),Scala211,[18..21) in Input.String("{ /* hello */ def foo(bar: Int) = bar }"))
x : foo
x.origin: Transformed(bar)
x : baz
x.origin: Parsed(Input.String("{ /* hello */ def foo(bar: Int) = bar }"),Scala211,[27..30) in Input.String("{ /* hello */ def foo(bar: Int) = bar }"))
x : Int
x.origin: Transformed(bar: Int)
x : baz: Int
x.origin: Transformed(bar)
x : baz
x.origin: Transformed(def foo(bar: Int) = bar)
x : def foo(baz: Int) = baz
res1: scala.meta.Tree =
{
def foo(baz: Int) = baz
}
scala>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment