I want to know how can I define, in a grammar file, that a Node of an AST has "two parents". If for example, the node 'D' of the first tree is also child of the node 'A', what syntax should I use so that node 'D' not appear repeated (I want something like the second tree).
A
|
|
|-------|
B C
|
D
A
/ \
/ |
|----| |
B C |
\ |
D
If I use something like:
A B C D -> ^(A B ^(C D) D)
Node 'D' will appear repeated.