'unparsing' the AST [message #501722] |
Thu, 03 December 2009 10:25  |
Eclipse User |
|
|
|
Hello everyone,
I'm fairly new to DLTK so please forgive me if this is a noobish question.
I'm using PDT [1] 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?
regards
raph
[1] http://www.eclipse.org/pdt/
|
|
|
Re: 'unparsing' the AST [message #501852 is a reply to message #501722] |
Thu, 03 December 2009 23:29  |
Eclipse User |
|
|
|
Hi Raphael,
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 pdt-dev@eclipse.org mailing
list, probably PDT has something useful for your task.
Regards,
Alex
|
|
|
Powered by
FUDForum. Page generated in 0.04056 seconds