Trivial parsing and generating DCG

See: Controlling backtracking in a DCG grammar?

That will not directly answer your question, but addresses the problem of having a DCG parse and generate while trying to keep to the original DCG for parsing as close as possible and yet still work for generating.

Also see this StackOverflow answer: Is it appropriate for a parser DCG to not be deterministic?