Java Reference
In-Depth Information
class NodeVisitor
procedure visit
( n )
foreach c n . getChildren() do call c . accept( this )
C
hildren
end
end
class SemanticsVisitor extends NodeVisitor
procedure
( c )
if c . type Boolean and c . type errorType
then call
check
B
oolean
1
error
(” Require Boolean type at
, c )
end
procedure
visit
( IfTesting ifn )
2
call visit
C
hildren
( ifn )
call check
B
oolean
( ifn . condition )
end
procedure
visit
(WhileLooping wn )
3
call
visit
C
hildren
( wn )
call
check
B
oolean
( wn . condition )
end
procedure
visit
(DoWhileLooping dwn )
4
call
visit
C
hildren
( dwn )
call
check
B
oolean
( dwn . condition )
end
procedure
visit
(ForLooping fn )
5
call open
S
cope
()
call
visit
C
hildren
( fn )
if
fn . condition
null
then call
check
B
oolean
( fn . condition )
call
close
S
cope
()
end
procedure
visit
( LabeledStmt ls )
/
Figure 9.11 on page 357
/
end
procedure
visit
(Continuing cn )
/
Figure 9.12 on page 358
/
end
procedure visit
(Breaking bn )
/
Figure 9.15 on page 360
/
end
procedure
visit
(Returning rn )
/
Figure 9.18 on page 362
/
end
end
Figure 9.1: Semantic Analysis Visitors (Part 1)
 
Search WWH ::




Custom Search