I made the following change:
string_termList(String,Terms) :-
prolog_grammar(PG), % from pl_grammar
% peg_parse(PG,String,'Prolog'(Nodes)),
peg_parse(PG,String,'Prolog'(Nodes),_,[verbose(silent)]),
nodes_terms(Nodes,Terms).
Now its silent:
?- string_termList("- x4 ** x2 =:= .", [Y]).
false.
And I can now also add failure handling in my adapter. The problem is
a parser that fails, and gets not catched by my adapter, avoids the X \== Y
check here, and gives false statistics. So I need to change my adapter:
Edit 02.05.2022:
Here are some test results. fuzz3.p can do parenthesis test cases
and fuzz4.p can provoke peg_parse errors. Both do not try to touch
the highly ambiguous cases.
Interestingly SWI agrees with my simplified parser, but disagrees
when I add peg_parse errors:
/* fuzz3.p, with parenthesis */
?- aggregate_all(count, (between(1,10000,_), random_expr(0, _, L, []),
| ppeg_parse(L, X), simp_parse(L, Y), X \== Y), C).
C = 899.
?- aggregate_all(count, (between(1,10000,_), random_expr(0, _, L, []),
| swi_parse(L, X), simp_parse(L, Y), X \== Y), C).
C = 0.
/* fuzz4.p, with parenthesis and provocation of peg_parse errors */
?- aggregate_all(count, (between(1,10000,_), random_expr(0, _, L, []),
| ppeg_parse(L, X), simp_parse(L, Y), X \== Y), C).
C = 705.
?- aggregate_all(count, (between(1,10000,_), random_expr(0, _, L, []),
| swi_parse(L, X), simp_parse(L, Y), X \== Y), C).
C = 302.
Maybe there are some explanations for these differences. One
example is already the SICStus and SWI-Prolog difference posted
a few hours ago. My simplified parser agrees with SICStus.