Debugging a Parser
Debugging a CUP-generated parser can be quite a challenge.
I have found that 9 times out of 10 the problem is due to errors with the input and/or with the lexer.
When I encounter a bug I back off of the parser, and focus on the lexer. I set the lexer to simply output the tokens that it would be serving up to the parser. This way I can check to see if it is serving up the correct tokens.