From: Mark Thom Date: Sun, 21 Oct 2018 05:37:09 +0000 (-0600) Subject: make lists parse properly when used as dcg rules X-Git-Tag: v0.8.110~327 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=1e3891204e023551b32854ebc2cb1625a55c717a;p=scryer-prolog.git make lists parse properly when used as dcg rules --- diff --git a/src/prolog/lib/dcgs.pl b/src/prolog/lib/dcgs.pl index 43cbaad1..d6d2f759 100644 --- a/src/prolog/lib/dcgs.pl +++ b/src/prolog/lib/dcgs.pl @@ -4,10 +4,10 @@ :- op(1200, xfx, -->). +phrase(G, G) :- + nonvar(G), G = [_|_], !. %, append(G, _, Ls0). phrase(G, Ls0) :- - nonvar(G), G = [_|_], !, append(G, _, Ls0). -phrase(G, Ls0) :- - nonvar(G), G = (G1, G2), !, phrase(G1, Ls0, Ls1), phrase(G2, Ls1). + nonvar(G), G = (G1, G2), !, phrase(G1, Ls0, Ls1), phrase(G2, Ls1, []). phrase(G, Ls0) :- call(G, Ls0, []).