[comp.lang.prolog] DCG expansion pitfall

matsc@sics.se (Mats Carlsson) (09/05/89)

Implementors and users, check how your favourite Prolog expands the
DCG clause:

p(X) -->
	(   {test(X)} -> []
	;   [token(X)]
	).

It should expand to something equivalent to

p(A, B, C) :-
        (    test(A) ->
             B = C
        ;    B = [token(A)|C]
        ).

This is yet another example of the unfortunate fact that (P;Q) is not
equivalent to ((true,P);Q) if P = (If->Then).
--
Mats Carlsson
SICS, PO Box 1263, S-164 28  KISTA, Sweden    Internet: matsc@sics.se
Tel: +46 8 7521543      Ttx: 812 61 54 SICS S      Fax: +46 8 7517230

ok@cs.mu.oz.au (Richard O'Keefe) (09/05/89)

In article <MATSC.89Sep5092248@skarabe.sics.se>, matsc@sics.se (Mats Carlsson) write
warned of a bug in some grammar rule translators.  This bug was present in the
semi-public-domain grammar rule translator I posted here last year; did the
May 1989 version (which had the correction) make it out to the net?