Say I want to make a rule dependency graph for a Prolog program in Prolog. For example, the following program
foo(X) :- bar(X, 0).
bar(A, B) :- quux(A), coox(B).
baz.
will result in the following: true (using assert):
depends(foo, [bar]).
depends(bar, [quux, coox]).
depends(baz, []).
Or something like the above that I could easily use to create a graph. The approach I was thinking of is reading the lines of the input file as lines and doing a simple simple search and replace with them, but it looks like an ugly, non-prologue hack. Any other options that use the Prolog's metalogical features?
source
share