]> Repositorios git - scryer-prolog.git/commitdiff
catch attribute_goals errors in copy_term/3, don't discard variable module qualifiers...
authorMark Thom <[email protected]>
Tue, 21 Feb 2023 07:50:31 +0000 (00:50 -0700)
committerMark Thom <[email protected]>
Tue, 21 Feb 2023 07:50:46 +0000 (00:50 -0700)
src/lib/dcgs.pl
src/machine/project_attributes.pl

index 33b4c129403cbe14e1957302f970d8fc7e6274a5..1767d2bb0177581740763006609520dee762ab70 100644 (file)
@@ -75,13 +75,6 @@ phrase(GRBody, S0, S) :-
     ;  call(M:GRBody1, S0, S)
     ).
 
-
-module_call_qualified(M, Call, Call1) :-
-    (  nonvar(M) -> Call1 = M:Call
-    ;  Call = Call1
-    ).
-
-
 % The same version of the below two dcg_rule clauses, but with module scoping.
 dcg_rule(( M:NonTerminal, Terminals --> GRBody ), ( M:Head :- Body )) :-
     dcg_non_terminal(NonTerminal, S0, S, Head),
@@ -127,7 +120,10 @@ dcg_body(NonTerminal, S0, S, Goal1) :-
     NonTerminal \= ( \+ _ ),
     loader:strip_module(NonTerminal, M, NonTerminal0),
     dcg_non_terminal(NonTerminal0, S0, S, Goal0),
-    module_call_qualified(M, Goal0, Goal1).
+    (  functor(NonTerminal, (:), 2) ->
+       Goal1 = M:Goal0
+    ;  Goal1 = Goal0
+    ).
 
 % The following constructs in a grammar rule body
 % are defined in the corresponding subclauses.
index 0c51096ea370c99ff1c2f52de9d8e83cbe1228a9..59ad07904efa9262a33de05cb221a07e65d706f7 100644 (file)
@@ -90,12 +90,21 @@ copy_attribute_modules([Module:_|Attrs]) -->
     [Module],
     copy_attribute_modules(Attrs).
 
+attribute_goals_or_fail(M, V, V0, V1) :-
+    (  catch(M:attribute_goals(V, V0, V1),
+             E,
+             '$project_atts':'$print_attribute_goals_exception'(M, E)
+            ) ->
+       true
+    ;  V0 = V1
+    ).
+
 gather_residual_goals([]) --> [].
 gather_residual_goals([V|Vs]) -->
     { '$get_attr_list'(V, Attrs),
       phrase(copy_attribute_modules(Attrs), Modules0),
       sort(Modules0, Modules) },
-    foldl(V+\M^phrase(M:attribute_goals(V)), Modules),
+    foldl(V+\M^attribute_goals_or_fail(M, V), Modules),
     gather_residual_goals(Vs).
 
 delete_all_attributes_from_var(V) :- '$delete_all_attributes_from_var'(V).
@@ -105,6 +114,6 @@ copy_term(Term, Copy, Gs) :-
    findall(Term-Rs, term_residual_goals(Term,Rs), [Copy-Gs]).
 
 term_residual_goals(Term,Rs) :-
-   '$term_attributed_variables'(Term, Vs),
-   phrase(gather_residual_goals(Vs), Rs),
-   maplist(delete_all_attributes_from_var, Vs).
+    '$term_attributed_variables'(Term, Vs),
+    phrase(gather_residual_goals(Vs), Rs),
+    maplist(delete_all_attributes_from_var, Vs).