fix DCG bugs

This commit is contained in:
Mark Thom
2018-10-10 21:30:40 -06:00
parent 5586aa7057
commit 24a7206021
2 changed files with 6 additions and 4 deletions

View 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) :-