This is my grammar file
exp
: exp operatorMulDivMod exp #expMulDivMod
| exp operatorAddSub exp #expAddSub
;
varAssign
: variable '=' exp
| variable '+=' exp
| variable '-=' exp
| variable '*=' exp
| variable '/=' exp
| variable '.=' exp
I can process varAssign
rules separately using my visitors, however I'd like to rewrite those rules such that I won't need to create separate visitor from them. I would like if I can do vaAssign -> equivalent exp expression
. For example, if input is var += 2
, can I rewrite it as var = var + 2
so that it is caught by my exp
rule? I am using C# and antlr 4.4.5.3
Thank you