]> Repositorios git - scryer-prolog.git/commitdiff
introduce cuts over indexed (:)/2 of dcgs:phrase_/3 (#786)
authorMark Thom <[email protected]>
Wed, 3 Feb 2021 23:03:12 +0000 (16:03 -0700)
committerMark Thom <[email protected]>
Wed, 3 Feb 2021 23:03:15 +0000 (16:03 -0700)
src/lib/dcgs.pl

index a33c870bba2b3cc10fbf5c2452be7d33754b4e4c..07b82b951188d0cb8f617dedbb5f74e90a90a6ad 100644 (file)
@@ -31,11 +31,12 @@ phrase(GRBody, S0, S) :-
 
 phrase_([], S, S).
 phrase_(!, S, S).
-phrase_(_:[], S, S).
-phrase_(_:!, S, S).
+phrase_(_:[], S, S) :- !.
+phrase_(_:!, S, S) :- !.
 phrase_((A, B), S0, S) :-
     phrase(A, S0, S1), phrase(B, S1, S).
 phrase_(M:(A, B), S0, S) :-
+    !,
     phrase(M:A, S0, S1), phrase(M:B, S1, S).
 phrase_((A -> B ; C), S0, S) :-
     !,
@@ -52,26 +53,32 @@ phrase_(M:(A -> B ; C), S0, S) :-
 phrase_((A ; B), S0, S) :-
     (  phrase(A, S0, S) ; phrase(B, S0, S)  ).
 phrase_(M:(A ; B), S0, S) :-
+    !,
     (  phrase(M:A, S0, S) ; phrase(M:B, S0, S)  ).
 phrase_((A | B), S0, S) :-
     (  phrase(A, S0, S) ; phrase(B, S0, S)  ).
 phrase_(M:(A | B), S0, S) :-
+    !,
     (  phrase(M:A, S0, S) ; phrase(M:B, S0, S)  ).
 phrase_({G}, S0, S) :-
     (  call(G), S0 = S  ).
 phrase_(M:{G}, S0, S) :-
+    !,
     (  call(M:G), S0 = S  ).
 phrase_(call(G), S0, S) :-
     call(G, S0, S).
 phrase_(M:call(G), S0, S) :-
+    !,
     call(M:G, S0, S).
 phrase_((A -> B), S0, S) :-
     phrase((A -> B ; fail), S0, S).
 phrase_(M:(A -> B), S0, S) :-
+    !,
     phrase((M:A -> M:B ; fail), S0, S).
 phrase_(phrase(NonTerminal), S0, S) :-
     phrase(NonTerminal, S0, S).
 phrase_(M:phrase(NonTerminal), S0, S) :-
+    !,
     phrase(M:NonTerminal, S0, S).
 phrase_([T|Ts], S0, S) :-
     append([T|Ts], S, S0).