make attribute_goals a nonterminal

This commit is contained in:
Mark Thom
2019-10-03 23:29:18 -06:00
parent b61ed65208
commit 0a84f183fe
5 changed files with 41 additions and 42 deletions

View File

@@ -1,6 +1,7 @@
:- module(freeze, [freeze/2]).
:- use_module(library(atts)).
:- use_module(library(dcgs)).
:- attribute frozen/1.
@@ -20,13 +21,14 @@ freeze(X, Goal) :-
put_atts(Fresh, frozen(Goal)),
Fresh = X.
gather_freeze_goals(Attrs, _, _) :-
var(Attrs), !.
gather_freeze_goals([frozen(X) | _], Var, [freeze(Var, X) | _]) :-
!.
gather_freeze_goals([_ | Attrs], Var, Goals) :-
gather_freeze_goals(Attrs, Var, Goals).
gather_freeze_goals(Attrs, _) -->
{ var(Attrs), ! }.
gather_freeze_goals([frozen(X) | _], Var) -->
[freeze(Var, X)],
{ ! }.
gather_freeze_goals([_ | Attrs], Var) -->
gather_freeze_goals(Attrs, Var).
attribute_goals(X, Goals) :-
'$get_attr_list'(X, Attrs),
gather_freeze_goals(Attrs, X, Goals).
attribute_goals(X) -->
{ '$get_attr_list'(X, Attrs) },
gather_freeze_goals(Attrs, X).