Sujet : Mode yfy to the rescue (Was: How Prolog became an education nightmare)
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prologDate : 14. Nov 2024, 22:30:11
Autres entêtes
Message-ID : <vh5q52$6gk9$1@solani.org>
References : 1 2 3
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
Ok, here is my minimal test case, to
demonstrate that fy 2 yf has not much
practical use. Irrespective how it is
parsed. The test case is the computer
science professor who wants to teach
compiler construction, and defines a
toy language that has among other things
a Pascal begin end:
:- op(1100, fy, begin).
:- op(1100, yf, end).
Neither SWI-Prolog nor SICStus Prolog can parse this:
?- X = (begin x=1 end; begin y=2 end).
ERROR: Syntax error: Operator priority clash
I am also not able to parse it in Dogelog
Player, Trealla Prolog and Scryer Prolog.
I guess it has to do that disjunction uses
xfy mode. Mostlikely yfx mode would also not
help? What would help if there were
a yfy mode (sic!).
Mild Shock schrieb:
Concerning the input (xxx yyy zzz) the OP wrote:
I would expect it to print zzz(xxx(yyy)).
Where did he get this requirement from, he didn’t
compare other Prolog systems, right? So it came from
his applicationdomain. But what was his application
domain? Ok, lets proceed to an example with multiple
brakets. Lets make the Pascal “begin” “end” example,
by replacing xxx and zzz by “begin” and “end”.
I get this result:
?- member(X,[begin,end]), current_op(Y,Z,X).
X = (begin), Y = 1100, Z = fy ;
X = (end), Y = 1100, Z = yf.
?- X = (begin
| x = 1;
| y = 2;
| begin
| z = 3
| end
| end).
X = (begin x=1;y=2;begin z=3 end end).
But is the abstract parse term, the Prolog result useful?