How can I obtain the yield of (sub)parse tree in Rascal, i.e., the text that is associated to a subtree? For ex., during a visit I encounter a Declaration (with Java/M3) and now I want to get the text of this declaration. I have tried "unparse", but this gives "does not match any of the declared (overloaded) signature patterns :unparse(Tree)", I guess that it works only for a top sort/starting symbol.
Asked
Active
Viewed 124 times
1 Answers
1
One of the simplest solutions is using a string template and inserting your subtree in it -- assuming that your subtree is d
:
"<d>"
This will automatically unparse d
. More sophisticated pretty printing is currently missing but is on our todo list.

Paul Klint
- 1,418
- 7
- 12