Here is some gramma wich represents tree
<tree> -> *
<tree> -> (<tree><tree>)
where * means leaf and couple of trees in parentheses describes root that sons are trees in parentheses.
i Have to rewrite that gramma to dcg and add semantic actions which will create abstrac tree of that tree whith leaf/0 and node/2 example node(node(leaf,leaf),node(leaf,leaf))
for any idea or source i will be gratefull.
This works in my SWI-Prolog:
In order to parse a string you need to call
phrasepredicate, for example:Prolog will unify X with abstract representation of tree from string.