I'm trying to "translate" a file that contains dcg's. in particular i am trying to transform all dcg into normal definite clauses using expand_term/2
, however i would like to avoid manually translating all dcgs, so i would try to translate all clauses of the file at once (e.g. passing the whole file) . is there any way to do it?
for example, suppose we have a temp.pl
file which contains some dcg:
a(X,Y) --> b(X), c(Y).
d([A | Ax]) --> b(A).
....
....
instead of using expand_term/2
individually for each term, like:
?- expand_term((a(X,Y) --> b(X), c(Y)), Clause).
Clause = [(:-non_terminal(user:a/4)), (a(X, Y, _A, _B):-b(X, _A, _C), c(Y, _C, _B))].
And then replace the dcg with definite clause in file.
I would like to pass for example the whole file (to a clause for example ) which contains the dcg, and translate all the dcg at once and print in a file or as an output, I don't know.