I did not look at your code in detail but from the description it might be related to code Jan W. has created for building SWI-Prolog, e.g. library/build
It seems that Jan code is to manage build systems like CMake or Make.
Ce pack I have written is to help generate a ninja build file, much like what CMake does when generating a ninja build file or makefile.
By the way, I’ve recently stumbled across one of your comment here about a dcg to parse postscript.
However, you only posted test case for the grammar and not the grammar itself.
Would it be possible to share the grammar ?
I would be very interested in a DCG that can parse postscript/pdf files.