S - Intranet - Department of Computer Science: Login
S - Intranet - Department of Computer Science: Login
S - Intranet - Department of Computer Science: Login
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Using SableCC’s Visitor Pattern<br />
The main way <strong>of</strong> using SableCC’s visitor pattern is to define a<br />
class which extends DepthFirstAdapter.<br />
By over-riding the methods inAAssignStm or<br />
outAAssignStm etc. we can specify code to be executed<br />
when entering or leaving each node during a depth first traversal<br />
<strong>of</strong> the syntax tree.<br />
If we want to modify the order <strong>of</strong> traversal then we can over-ride<br />
caseAAssignStm etc. but this is <strong>of</strong>ten not necessary.<br />
The in and out methods return void, but the class provides<br />
HashTable in, out; which we can use to store types <strong>of</strong><br />
expressions.<br />
72