Today's riddle is this:
Why is the code for the semantic actions generated in a separate class?Here are some possible answers:
- Your guess is as good as mine.
- Look in the user manual to find out --- oh wait, the user manual doesn't explain this.
- To ensure that you must violate encapsulation in order to allow semantic actions to refer to internal parser operations?
The action code can refer to the parser via a field called parser, but that's only useful for calling public methods on the parser object. But that means that any internal parser state/operations that the semantic actions want to access must be exposed as public, violating encapsulation.