How to match the empty case in CUP parser grammar
问题 I am using CUP to generate a parser, and I want an empty file to be an acceptable program. I have tried add the empty case to my start symbol, based off the response to a similar question here. start with prog; /* The grammar rules */ prog ::= class_block:cb | class_block:cb stmts:sb | stmts:sb | // desired empty case ; Including the desired empty case gives me the following error: parser.java:516: error: incompatible types: Object cannot be converted to Symbol CUP$parser$result = parser