I'm trying to allow my grammar to support variable declarations where you don't have to repeat the variable type such as int i = 3, j = 4, k;
The problem I have is with my generated tree. This is my rule...
varDeclaration
: type ID (ASSIGN expression)? (COMMA ID (ASSIGN expression)?)* SEMICOLON -> ^(VAR_DECL type ID expression?)+;
It successfully splits apart the declaration into separate variable declarations, but it is repeating the expression tree for all of them.
So for int x = 4, y = 5
, they both have value 4
in the AST.
Any help with an operator or something I can use would be appreciated.