From 94392f248c9a00556a0fcc6d95e7f7fabe1a0853 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Wed, 3 Feb 2021 15:48:09 -0700 Subject: [PATCH] enable phrase_ rules for module resolved grammars (#785) --- src/lib/dcgs.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/dcgs.pl b/src/lib/dcgs.pl index 05f41cb0..a33c870b 100644 --- a/src/lib/dcgs.pl +++ b/src/lib/dcgs.pl @@ -31,6 +31,8 @@ phrase(GRBody, S0, 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) :- @@ -57,16 +59,24 @@ 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). +phrase_(_:[T|Ts], S0, S) :- + append([T|Ts], S, S0). % The same version of the below two dcg_rule clauses, but with module scoping. -- 2.54.0