From: Mark Thom Date: Thu, 11 Oct 2018 03:30:40 +0000 (-0600) Subject: fix DCG bugs X-Git-Tag: v0.8.110~334 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=24a72060215470ca9e55016227c352a255a21e3e;p=scryer-prolog.git fix DCG bugs --- diff --git a/README.md b/README.md index 7fb1e25e..16e6341c 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,7 @@ The following predicates are built-in to rusty-wam. * `numbervars/2` * `once/1` * `partial_string/2` +* `phrase/{2,3}` * `rational/1` * `read/1` * `repeat/0` diff --git a/src/prolog/lib/dcgs.pl b/src/prolog/lib/dcgs.pl index 6ff86a79..bbb9f5d2 100644 --- a/src/prolog/lib/dcgs.pl +++ b/src/prolog/lib/dcgs.pl @@ -41,11 +41,12 @@ term_expansion(Term0, (ModHead :- ModBody)) :- nonvar(Body), expand_body(Body, ModBody, 0, N). -expand_body((Term, Terms), (ModTerm, ModTerms), N0, N) :- - !, expand_body_term(Term, ModTerm, N0, N1), +expand_body(Term0, (ModTerm, ModTerms), N0, N) :- + nonvar(Term0), Term0 = (Term, Terms), !, + expand_body_term(Term, ModTerm, N0, N1), expand_body(Terms, ModTerms, N1, N). -expand_body(Term, ModTerm, N0, N) :- - expand_body_term(Term, ModTerm, N0, N). +expand_body(Term0, ModTerm, N0, N) :- + nonvar(Term0), expand_body_term(Term0, ModTerm, N0, N). expand_body_term([], true, N, N) :- !. expand_body_term([Arg|Args], ModTerm, N0, N) :-