is there a way to controll the reduction operation of a token with ANTLR at runtime. For example, I've an ANTLR grammar that looks like:
s: ( a | b);
a: WORD;
b: WORD;
WORD: ('a'..'z')+
Where the exact possible values related to both 'a' and 'b' are known at runtime, i.e. I want to decide at runtime whether to reduce a WORD to 'a' or 'b'.
Use a semantic predicate. Unless you plan on adding actions to rules a and b, this example won't be particularly useful.