Open timotheecour opened 10 years ago
There is indeed no predefined operator for that.
Maybe with a semantic action? I'm not sure if that can be done, since an operator or a semantic action must return a parse tree. And an array of children is not a parse tree. Inside the semantic action, you do not have access to the parent tree...
A possible, more intrusive change would be to modify the sequence code to recognize a folded node and 'pull it upward', keeping only its children. Hmm...
Here's an example of what I want to have: A -> fold(B) C B -> B1 / B2
In the parse tree, the operation fold(B) replaces B by it's children so that B doesn't appear (only B1 or B2) This makes for shorted parse trees. eg:
A(B(B1),C) would become after applying the 'fold': A(B1,C)
of course it wouldn't be called fold() but maybe %B or some other yet unused symbol