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
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
Get step-by-step solutions from verified subject matter experts
