Question: Use the visitor design pattern to create another example visitor class, say NumberCollector, which collects all numbers that appear in the AST in a list.

Use the visitor design pattern to create another example visitor class, say NumberCollector, which collects all numbers that appear in the AST in a list. For example, three numbers, “3,” “4,” and “2,” appear in the AST of the program “(+ 3 4 2).” The methods in NumberCollector also should not use any global or static variables. The NumberCollector class should not have any fields.

Step by Step Solution

3.42 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

In the visitor design pattern the operation applied to objects depends on both their class and the class of the visitor Thus a class that collects num... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related An Experiential Introduction To Principles Of Programming Languages Questions!