I need to transform text from following structure:
{ A1 A2 { B1 B2 { C1 C2 } } }
to the following developed/flattened structure:
{ A1 }
{ A2 B1 }
{ A2 B2 C1 }
{ A2 B2 C2 }
I use the following Antlr grammar to parse the file:
grammar tree;
node : '{' (STRING | node)* '}';
STRING : ('A' .. 'Z' | '0' .. '9')+;
WS : ( ' ' | '\t' | '\n' | '\r') -> channel(HIDDEN);
Is it possible to perform the Ast transformation by only using inline Antlr rewrite rules (using ->
)?