Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » 'unparsing' the AST
'unparsing' the AST [message #501722] Thu, 03 December 2009 10:25 Go to next message
raph  is currently offline raph
Messages: 2
Registered: December 2009
Junior Member
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 Go to previous message
Alex Panchenko is currently offline Alex Panchenko
Messages: 342
Registered: July 2009
Senior Member
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
Previous Topic:[BUILD] I-I200912031744-200912031744
Next Topic:Javascript
Goto Forum:
  


Current Time: Thu Apr 24 14:58:55 EDT 2014

Powered by FUDForum. Page generated in 0.02267 seconds