views:

55

answers:

1

Can I use the AST / JDT for other languages? for example to write my own parser for C# that uses somehow the AST technology?

+4  A: 

If you look at the article "Eclipse JDT - Abstract Syntax Tree (AST) and the Java Model - Tutorial", JDT and its AST are tailored for Java.

The Eclipse Java Development Tools (JDT) provide APIs to access and manipulate Java source code.
The AST is a detailed tree representation of Java source code. The AST defines API to modify, create, read and delete source code.
The package for AST is org.eclipse.jdt.core.dom in the Eclipse org.eclipse.jdt.core plugin.

Other AST exists for other languages, and for generating your own, you could use XText

alt text

But the one in a jdt package is speicialized for Java.
It can be viewed through an ASTView

alt text

See also the Exploring Eclipse's ASTParser article as another illustration of the Java-oriented aspect of eclipse AST manipulations.

VonC