Deutsch   English   Français   Italiano  
<vgvseq$3e31$2@solani.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.roellig-ltd.de!open-news-network.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: Mild Shock <janburse@fastmail.fm>
Newsgroups: comp.lang.prolog
Subject: Re: How Prolog became an education nightmare (Was: 50 Years of Prolog
 Nonsense)
Date: Tue, 12 Nov 2024 16:32:44 +0100
Message-ID: <vgvseq$3e31$2@solani.org>
References: <db903ba2-8ccd-418e-bd18-a9eb381cd222n@googlegroups.com>
 <e5616850-37a8-46fd-b2a8-e3ca252b8a5an@googlegroups.com>
 <vgvsb7$3e31$1@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 12 Nov 2024 15:32:42 -0000 (UTC)
Injection-Info: solani.org;
	logging-data="112737"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
 Firefox/91.0 SeaMonkey/2.53.19
Cancel-Lock: sha1:4d5WFH6p54st/Dbmx5E9JWW9TiM=
In-Reply-To: <vgvsb7$3e31$1@solani.org>
X-User-ID: eJwNxkkBwDAIBEBLnEuQEyD4l9DOa1zB6DA4zNe39kmAtoRZKRuuhKRnRi4qV6SIZ3sz5qQMe/YxxH36B/UBMIMUog==
Bytes: 3142
Lines: 66

Here is the SWI-Prolog and the SICStus
Prolog abstract parse term. This is the real
nightmare of every computer science professor,

who wants to use Prolog in a compiler
construction course:

/* SWI-Prolog 9.3.14 */
end(end(begin(;(=(x,1),;(=(y,2),begin(=(z,3)))))))

/* SICStus Prolog 4.9.0 */
begin(;(=(x,1),;(=(y,2),begin(end(end(=(z,3)))))))

On the other hand mostlikely the OP @horsh
would expect:

/* What the End-User wants */
end(begin(;(=(x,1),;(=(y,2),end(begin(=(z,3)))))))

I think its impossible to do in any Prolog system,
you would need a programming language with the
possibility to do mixfix syntax definitions,

like for example in Isabelle/HOL:

(* Define the mixfix syntax for a Pascal-like block *)
syntax
   "_begin_end" :: "'a ⇒ 'a" ("begin _ end")

Or otherwise use DCG to write your own parser
for the DSL at hand, that you want to parse.
Since Prolog operators cannot model mixfix syntax,

at least SWI-Prolog and SICStus Prolog fail,
and I guess other Prolog systems fail as well.

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?
>