Question

Is it possible to do what I'm attempting here? Or, perhaps I'm approaching it wrong?

arrayDef
  : { int c = 0; }
    ('['']' {c++;})+
  -> ARRAY /* somehow inject c here */
  ;
Was it helpful?

Solution

Why not use the ChildCount of your ARRAY tree node?

arrayDef
    :   ('[' ']')+
        -> ^(ARRAY '['+)
    ;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top