This is a tool that shows the abstract syntax tree as found by the JavaStyle parser. (this might be slightly different from that which you would expect from the Java Language Specification).
public class X {
public X() {
int y = 1;
}
}
has the tree
CompilationUnit
TypeDeclaration
ClassDeclaration (public )
UnmodifiedClassDeclaration X
ClassBody
ClassBodyDeclaration
ConstructorDeclaration X (public )
FormalParameters
BlockStatement
LocalVariableDeclaration
Type
PrimitiveType int
VariableDeclarator
VariableDeclaratorId y
VariableInitializer
Expression
ConditionalExpression
ConditionalOrExpression
ConditionalAndExpression
InclusiveOrExpression
ExclusiveOrExpression
AndExpression
EqualityExpression
InstanceOfExpression
RelationalExpression
ShiftExpression
AdditiveExpression
MultiplicativeExpression
UnaryExpression
UnaryExpressionNotPlusMinus
PostfixExpression
PrimaryExpression
PrimaryPrefix
Literal 1
performing the XPath query
//Literal
gives the result
ASTLiteral at line 3
Last Modified: 30 October 2003