]> Repositorios git - scryer-prolog.git/commitdiff
fix DCG bugs
authorMark Thom <[email protected]>
Thu, 11 Oct 2018 03:30:40 +0000 (21:30 -0600)
committerMark Thom <[email protected]>
Thu, 11 Oct 2018 03:30:40 +0000 (21:30 -0600)
README.md
src/prolog/lib/dcgs.pl

index 7fb1e25e8faf9483e1d56eedb4ad16bdf1fd755f..16e6341cfcbfe20b82eef225d2a040620933a539 100644 (file)
--- 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`
index 6ff86a79b04ff97ec5c30174ea7e55477e913aa4..bbb9f5d280d038df361eb7f752ab57b42e65fc1a 100644 (file)
@@ -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) :-