Skip to main content


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 15:25 Go to next message
raph  is currently offline raph Friend
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] Fri, 04 December 2009 04:29 Go to previous message
Alex Panchenko is currently offline Alex PanchenkoFriend
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: Fri Apr 19 21:27:52 GMT 2024

Powered by FUDForum. Page generated in 0.03535 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top