Example AST | |
=========== | |
The Java program shown in source form first is followed by a representation | |
of of its AST. | |
================ | |
package com.example; | |
import java.util.*; | |
public class HelloWorld { | |
public static void main(String[] args) { | |
System.out.println("Hello" + " world"); | |
} | |
} | |
================ | |
<CompilationUnit | |
package: | |
<PackageDeclaration | |
name: | |
<QualifiedName | |
qualifier: <SimpleName identifier: "com"> | |
name: <SimpleName identifier: "example"> | |
> | |
> | |
imports: | |
[ | |
<ImportDeclaration | |
name: | |
<QualifiedName | |
qualifier: <SimpleName identifier: "java"> | |
name: <SimpleName identifier: "util"> | |
> | |
isOnDemand: true | |
> | |
] | |
types: | |
[ | |
<TypeDeclaration | |
isInterface: false | |
modifiers: IModifier.PUBLIC | |
name: | |
<SimpleName identifier: "HelloWorld"> | |
superclass: null | |
superInterfaces: [] | |
bodyDeclarations: | |
[ | |
<MethodDeclaration | |
isConstructor: false | |
modifiers: IModifier.PUBLIC | IModifier.STATIC | |
selector: <SimpleName identifier: "main"> | |
returnType: | |
<PrimitiveType primitiveTypeCode: PrimitiveType.VOID> | |
parameters: | |
[ | |
<SingleVariableDeclaration | |
modifiers: IModifier.NONE | |
type: | |
<ArrayType | |
componentType: | |
<SimpleType | |
name: | |
<SimpleName identifier: "String"> | |
> | |
> | |
> | |
name: | |
<SimpleName identifier: "args"> | |
initializer: null | |
> | |
] | |
thrownExceptions: [] | |
body: | |
<Block | |
statements: | |
[ | |
<ExpressionStatement | |
expression: | |
<MethodInvocation | |
expression: | |
<QualifiedName | |
qualifier: | |
<SimpleName identifier: "System"> | |
name: | |
<SimpleName identifier: "out"> | |
> | |
name: | |
<SimpleName identifier: "println"> | |
arguments: | |
[ | |
<InfixExpression | |
operator: InfixExpression.Operator.PLUS | |
leftOperand: | |
<StringLiteral escapedValue: "\"Hello\""> | |
rightOperand: | |
<StringLiteral escapedValue: "\" world\""> | |
extendedOperands: [] | |
> | |
] | |
> | |
] | |
> | |
] | |
> | |
> | |
] | |
] | |