Calculator.g4
grammar calculator;
expression: atom ((PLUS | MINUS) atom)*;
atom: '1';
PLUS: '+';
MINUS: '-';
WS: [ \r\n\t]+ -> skip;
Is there any examples to explain how to parse the pattern atom ((PLUS | MINUS) atom)*
I have searched a lot of blogs teaching how to parse the simple grammars in visitor and listener model. But, none of them show how to parse the pattern like atom ((PLUS | MINUS) atom)*.
What I am confused is the PLUS/MINUS are different, I can use method AllAtom to range over atoms, but there is no method to get the related PLUS/MINUS. There should be a list of PLUS/MINUS, which may be different from each other.