Skip to content

Commit

Permalink
Remove DCGs that have thrown an exception during term expansion
Browse files Browse the repository at this point in the history
Some DCG constructs aren't supported and can't be expanded, here we
remove offending DCG rule and don't compile it at all – in a similar
fashion to what we do when incorrect goal was found – whole predicate
isn't getting compiled.

Fixes mthom#2675
  • Loading branch information
hurufu committed Dec 5, 2024
1 parent ff03432 commit a172650
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/dcgs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
:- use_module(library(lists), [append/3, member/2]).
:- use_module(library(loader), [strip_module/3]).

:- dynamic(null/0).
:- initialization(abolish(null/0)).

:- meta_predicate phrase(2, ?).

:- meta_predicate phrase(2, ?, ?).
Expand Down Expand Up @@ -216,7 +219,7 @@

user:term_expansion(Term0, Term) :-
nonvar(Term0),
dcg_rule(Term0, Term).
catch(dcg_rule(Term0, Term), E, (Term = null, format(" ~q~n", [E]))).


%% seq(Seq)//
Expand Down

0 comments on commit a172650

Please sign in to comment.