Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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 Jun 13 23:10:22 EDT 2025

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

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

Back to the top