Well since its your code, it should be quite easy for you to extend this change:
op_associativityEq(fy,yfx,left) :- current_prolog_flag(iso, false).
op_associativityEq(fy,yfx,right) :- current_prolog_flag(iso, true).
/* Add further pairs that differ from what ISO core standard
specifies in Table 6 etc.. and what SWI-Prolog implements */
And you will also be able to play around with it conveniently:
?- op(9,fy,fy), op(9,yfx,yfx).
true.
?- string_termList("fy 1 yfx 2.", [T]), write_canonical(T), nl.
yfx(fy(1),2)
T = fy 1 yfx 2.
?- set_prolog_flag(iso, true).
true.
?- string_termList("fy 1 yfx 2.", [T]), write_canonical(T), nl.
fy(yfx(1,2))
T = fy 1 yfx 2.
?- set_prolog_flag(iso, false).
true.
/* Test more samples that differ from what ISO core standard
specifies in Table 6 etc.. and what SWI-Prolog implements */
Hope this Helpsā¦
Unfortunately, even if you, or Boris who offered help, have a complete list of
the pairs that differ, this does not yet allow you to update the C code of SWI-Prolog.
I suspect the unparse would also profit from some treatment, see below.
Otherwise you will be bugged by a parser and unparser that are not in sync.
Edit 13.04.2022:
But some writeq/1, what is usually used in the top-level for answer substitutions
do a better job than what SWI-Prolog built-in unparser does. Now both yfx(fy(1),2)
and fy(yfx(1,2))
are displayed as fy 1 yfx 2
:
/* SWI-Prolog */
?- op(9,fy,fy), op(9,yfx,yfx).
true.
?- T = yfx(fy(1),2).
T = fy 1 yfx 2.
?- T = fy(yfx(1,2)).
T = fy 1 yfx 2.
This should not be the case, and is a defect, since it obviously
leads to reparsing errors. I donāt get the same defect when
using ECLiPSe Prolog:
[eclipse 1]: op(9,fy,fy), op(9,yfx,yfx).
Yes (0.00s cpu)
[eclipse 2]: T = yfx(fy(1),2).
T = (fy 1) yfx 2
Yes (0.00s cpu)
[eclipse 3]: T = fy(yfx(1,2)).
T = fy 1 yfx 2
Yes (0.00s cpu)
But the exact placement of paranthesis must possibly then depend
on current_prolog_flag(iso, F)
for SWI-Prolog. Otherwise
reparsing goes also wrongā¦