I’m using: SWI-Prolog version 8.1.6
Here’s simplified version of a module I have.
:- module(parse_tools,[]).
:- use_module(library(dcg/basics)).
:- export(quot_csv//1).
quot_csv(Value) --> { var(Value) },`"`,string(Value),`"`,!,(`,`;eos).
quot_csv(DCG) --> `"`,DCG,`"`,!,(`,`;eos).
mdy(M,D,Y) --> blanks,integer(M),`/`,integer(D),`/`,integer(Y),string(_).
cash(Number) --> blanks,prefix,float(Number),string(_).
prefix,`0.` --> `$`,blanks,`.`,!.
prefix,`-` --> `-$`,blanks,!.
prefix --> `$`,blanks.
The intent is for calling program to be able to able to use something like:
phrase(lin(M,D,Y,Cash),Line,_),
% more stuff using M,D,Y and Cash.
lin(M,D,Y,Cash) --> quot_csv(mdy(M,D,Y)),quot_csv(cash(Cash)).
This works fine, but I want to allow the calling program to use its own custom DCG with quote_csv//1. But then quot_csv//1 won’t be able to find it since it’s in a different module. What is the most direct way to do this.
Thanks,
John