.NET package trunfold
This program is part of the Trash toolkit. trunfold <string> The unfold command applies the unfold transform to a collection of terminal nodes in the parse tree, which is identified with the supplied xpath expression. Prior to using this command, you must have the file parsed. An unfold operation substitutes the right-hand side of a parser or lexer rule into a reference of the rule name that occurs at the specified node. The resulting code is parsed and placed on the top of stack. Example: trparse A.g4 | trunfold ""//parserRuleSpec//labeledAlt//RULE_REF[text() = 'markerAnnotation']""