I'm using antlr4 with python2 target,
additive_expression returns [value] @init{$value = 0;}
: multiplicative_expression ((PLUS_OPERATOR | MINUS_OPERATOR) multiplicative_expression)*
Since the ((PLUS_OPERATOR | MINUS_OPERATOR) multiplicative_expression)
expression appears zero or multiple times,
I will need to access each of it separately then calculate the final value.
Any ideas? I've tried the following, non of them works
- use
re = (...)
and antlr says I can't define it for non-sets - use
op = (PLUS_OPERATOR | MINUS_OPERATOR)
etc. but it always point to the last appearance of the expression