Java Reference
In-Depth Information
1
StructReferencing
type
objectName
fieldName
2
3
ArrayReferencing
Identifier
type
type
attributeRef
arrayName
indexExpr
name (f)
5
4
BinaryExpr
StructReferencing
type
type
operator (+)
objectName
fieldName
leftExpr
rightExpr
6
7
8
9
Identifier
type
Identifier
type
Identifier
type
IntLiteral
type
attributeRef
attributeRef
attributeRef
value (1)
name (s)
name (a)
name (i)
Figure 8.39: AST for Array and Struct Example
6. The second iteration within the execution of
visit
C
hildren
for node 2
invokes the
accept
method for node 5.
7. The
visit
method at Marker
62
in Figure 8.33 is executed for node 5.
8. This method begins with a call to
visit
C
hildren
, which first invokes the
accept
method for node 8.
9. The meaning of name i is retrieved from the symbol table. Our assump-
tion in this example is that it is an integer, so
integer
is set as the value of
the
type
field on node 8. Control returns to the visitor for node 5.
10.
visit
visit
method at Marker
60
in Figure 8.33 immediately assigns
integer
as the
value of the
type
field in node 9 and then returns.
C
hildren
then invokes the
accept
method for node 9. The
11. The call to
method for the BinaryExprnode
will result in
integer
being assigned as the value of the
type
field in node
5. Control then returns to the visitor for node 2.
binary
R
esult
T
ype
in the
visit