|'unparsing' the AST [message #501722]
||Thu, 03 December 2009 10:25
Registered: December 2009
I'm fairly new to DLTK so please forgive me if this is a noobish question.
I'm using PDT  to parse PHP code and access a program's AST. Maybe I
can't see the forest for the trees, but how do I 'unparse' an AST back
into source code? Ideally, I wish to stay as close as possible to the
original code. I know that an ASTNode has getStart() and getEnd()
methods that I could use to get a node's original 'value', but surely
there must be a better way. From what I've seen an ASTNode does not
contain a reference to the original token.
By the way, is there a JavaDoc documentation for the DLTK API?
|Re: 'unparsing' the AST [message #501852 is a reply to message #501722]
||Thu, 03 December 2009 23:29
| Alex Panchenko
Registered: July 2009
Generally, printing AST back to source code requires a lot of additional
information like positions for every token. That's why JDT uses 2 AST
class hierarchies: AST used by compiler and DOM AST used by refactoring,
etc. At the moment DLTK doesn't provide common implementation of the DOM
AST, but this idea is regularly discussed.
I think you should ask this question in email@example.com mailing
list, probably PDT has something useful for your task.
Powered by FUDForum
. Page generated in 0.04351 seconds