|
What this is
Other links
The source code
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: []
>
]
>
]
>
]
>
>
]
]
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.