Only one way to do this: throw an exception:
locationPath returns [CustomParser xpathParser] : ^(LOCATION_PATH relativeLocationPath) {throw new RuntimeException("No way!");} | ^(LOCATION_PATH absoluteLocationPath {$xpathParser=$absoluteLocationPath.xpathParser;}) ;
If the compiler is still complaining (I don’t remember, and I can’t check right now), add if(true) in front of it:
locationPath returns [CustomParser xpathParser] : ^(LOCATION_PATH relativeLocationPath) {if(true) throw new RuntimeException("No way!");} | ^(LOCATION_PATH absoluteLocationPath {$xpathParser=$absoluteLocationPath.xpathParser;}) ;
source share