Suppose there is a type rule. This is either a predefined type (specified by IDENTIFIER) or a Descriptor type.
type
: IDENTIFIER
| typeDescriptor
;
In my program, I have an instance of typeContext 'ctx'. How to find out if the IDENTIFIER path is selected or the Descriptor type is selected.
I recognize one way to test ctx.IDENTIFIER() == nulland ctx.typeDescriptor() == null. But it seems that this does not work very well when there are many alternatives. Is there a way to return an index to indicate which rule is selected? Thank you
source
share