there are two problems in your grammar,
- assigning 3 different types to attribute 'ref'
- generating 3 different types by parsing some ID
I am not sure what do you want to do. But, I can give you an example. Hope it can help you.
e.g.
List:
'list' '(' elements += Element * ')';
Map:
'map' '(' pairs += Pair * ')';
GeneralDataType:
List | Map
CollectionGetElement:
val=[VariableReference] '='
ref = GeneralDataType
;