]> Repositorios git - scryer-prolog.git/commitdiff
capture and propagate (=..)/2 errors in phrase/{2,3} (#1460)
authorMark Thom <[email protected]>
Wed, 22 Jun 2022 04:47:55 +0000 (22:47 -0600)
committerMark Thom <[email protected]>
Wed, 22 Jun 2022 04:47:55 +0000 (22:47 -0600)
src/lib/dcgs.pl

index 4fe172f75f3e53d81119ecb2c82208f77c06b1f9..0c30447a417526e3d45aaab5daa595b2c3f416bb 100644 (file)
@@ -154,12 +154,17 @@ seqq([Es|Ess]) --> seq(Es), seqq(Ess).
 % Describes an arbitrary number of elements
 ... --> [] | [_], ... .
 
+
+error_goal(error(E, must_be/2), error(E, must_be/2)).
+error_goal(error(E, (=..)/2), error(E, (=..)/2)).
+error_goal(E, _) :- throw(E).
+
 user:goal_expansion(phrase(GRBody, S, S0), GRBody1) :-
     load_context(GRBody, M, GRBody0),
     nonvar(GRBody0),
     catch(dcgs:dcg_body(GRBody0, S, S0, GRBody1, M),
-          error(E, must_be/2),
-          (  GRBody1 = throw(error(E, must_be/2))  )
+          E,
+          dcgs:error_goal(E, GRBody1)
          ).
 
 user:goal_expansion(phrase(GRBody, S), phrase(GRBody, S, [])).