How to create shorthand for a rule without ambiguity?

48 views Asked by At

I have this in my grammar: (INF is short for influence)

inftype 
: 'INF' ('Attack'|'A')
| 'INF' ('Defend'|'D') 
| 'INF' ('Recharge'|'R')
;

This leads to ambiguity between INFA and INFAttack. Is there anyway to resolve this bar making two rules?

This does not work either:

inftype 
: 'INF' ('Attack'|'Defend'|'Recharge')
| 'INF' ('A'|'D'|'R')
;
1

There are 1 answers

1
Evgeni Petrov On

inftype : 'INFAttack' | 'INFDefend' | 'INFRecharge' | 'INFA' | 'INFD' | 'INFR' ;

Well, here is how it should be done :) I figure it out.