]> Repositorios git - scryer-prolog.git/commitdiff
lazily throw exceptions of dcg_body from goal-expanded phrase/{2,3} (#1244)
authorMark Thom <[email protected]>
Sat, 22 Jan 2022 19:22:50 +0000 (12:22 -0700)
committerMark Thom <[email protected]>
Sat, 22 Jan 2022 21:55:18 +0000 (14:55 -0700)
src/lib/dcgs.pl

index 7d6dd905041ffd9dd1b437cb2918cc9b9757895a..488c7a92e68cd6665298ee0e0bc55ed900eded5a 100644 (file)
@@ -156,6 +156,9 @@ seqq([Es|Ess]) --> seq(Es), seqq(Ess).
 user:goal_expansion(phrase(GRBody, S, S0), GRBody1) :-
     load_context(GRBody, M, GRBody0),
     nonvar(GRBody0),
-    dcg_body(GRBody0, S, S0, GRBody1, M).
+    catch(dcgs:dcg_body(GRBody0, S, S0, GRBody1, M),
+          error(E, must_be/2),
+          (  GRBody1 = throw(error(E, must_be/2))  )
+         ).
 
 user:goal_expansion(phrase(GRBody, S), phrase(GRBody, S, [])).