Recently do program analysis, need to parse Java source code, so went to see the abstract Syntax tree (AST, Chinese abstract syntax trees). A bit helpless is, online information on this aspect than I imagined less, may be involved in the bottom of the thing. AST is generally part of the compiler principle, but also often used for program analysis and so on. In short, you write a bunch of code, and the compiler converts the code into an abstract syntax tree for "understanding." Each tree node represents a code element, and it has its own attributes or something. The details of the AST one or two must not be clear, but the good news is that there are ready-made astparser in the Eclipse jdt that can parse the source code into an AST and have a very comprehensive node type and method for the user to manipulate.
Today, I'll start with some information on the internet about the jdt of the eclipse. And here, and so on, I feel like I will update this content in a timely manner.
That what, reprint please specify the source Oh ~ ~ ~ http://blog.csdn.net/flying881114/archive/2011/02/16/6187061.aspx
---Getting Started document
1. Eclipse Corner article:abstract Syntax Tree
Http://www.eclipse.org/articles/article.php?file=Article-JavaCodeManipulation_AST/index.html
(English, AST overview, little detail Code)
2. Explore Eclipse's Astparser
Http://www.ibm.com/developerworks/cn/opensource/os-ast/index.html#resources
(Chinese, relatively detailed explanation and code)
---AST use
1. Eclipse Jdt--ast and Javamodel Tutorial
Http://www.vogella.de/articles/EclipseJDT/article.html
(English, a lot of code, but need to have more background knowledge)
2. Eclipse AST Usage Guide
Http://wenku.baidu.com/view/a0b8e07931b765ce050814ac.html
(PDF document that describes the AST related classes and methods in more detail, which can be used in conjunction with Eclipse documentation)
3. Eclipse Documentation
http://help.eclipse.org/helios/index.jsp
In fact, the most reliable thing is to look directly at the eclipse documentation. Here you can understand everything you want to know.
4. Yet another AST tutorial
http://sahits.ch/blog/?p=228
English, there are a lot of code, from easy to difficult to explain (this article I have not read ~)
---use AST related
1. There is a problem with the AST. I don't know what jar package to use. Look here:
http://lym6520.javaeye.com/blog/747840
2. You want to see for yourself what the AST of your source files is. Install a Astview plugin for your eclipse.
http://www.eclipse.org/jdt/ui/astview/index.php
(Be careful.) Even the small program of Hello World has a very complicated ast oh. )