How can I catch errors? I tried:
?- ppeg_parse('0 xf yfx 1 xfy 2 xf xf yf xf', T).
% prolog_parser Error, operator clash in: 0 xf op(9,yfx,yfx) 1 ...
false.
?- swi_parse('0 xf yfx 1 xfy 2 xf xf yf xf', T).
T = syntax_error(operator_clash).
SWI-Prolog seems to emit an error and pPEG does what?
Display an error and fail? Was using this here:
% swi_parse(+Atom, -Term)
swi_parse(A, T) :-
catch(atom_to_term(A, T, _), error(T, _), true).
% ppeg_parse(+Atom, -Term)
ppeg_parse(A, T) :-
atom_concat(A, '.', B),
atom_string(B, C),
catch(string_termList(C, [T]), error(T, _), true).
Edit 15.04.2022:
Ok, a little mod of pl_parser.pl did the job:
% build_term_(Exp, VarsIn, _VarsOut, _Term) :-
% print_message(informational, prolog_parser(op_conflict(Exp,VarsIn))),
% fail.
build_term_(_, _, _VarsOut, _Term) :-
throw(error(syntax_error(operator_clash), _)).
Now I get:
?- ppeg_parse('0 xf yfx 1 xfy 2 xf xf yf xf', T).
T = syntax_error(operator_clash).