scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Unexpected syntax extension

Open UWN opened this issue 3 months ago • 8 comments

s#352.

?- op(1000,xfx,~>).
   true.
?- writeq([a~>b]).
   outputs("[(a~>b)]"), unexpected.
   syntax_error(...).

UWN avatar Oct 09 '25 09:10 UWN

6.3.3.1 Arguments ...

           arg =  term ;
Abstract:  a      a
Priority:         999

UWN avatar Oct 09 '25 09:10 UWN

Interesting. I thought it was weird that doing exactly 1000 priority worked, because that is the same priority as (',')/2. It also seems to be a problem in Trealla.

bakaq avatar Oct 09 '25 13:10 bakaq

Interesting. I thought it was weird that doing exactly 1000 priority worked, ...

Seems to be related to the specific parsing method, since also Prolog IV shows the same behavior. And only for xfx.

(Trealla does permit any priority for the arguments, like SWI. Even [a:-b,c].

UWN avatar Oct 09 '25 16:10 UWN

And only for xfx.

And yfx.

UWN avatar Oct 10 '25 08:10 UWN

?- op(1000,xfx,~>).
   true.
?- writeq([a~>b]).
   syntax_error(...).
?- op(1000,yfx,~>).
   true.
?- writeq([a~>b]).
   syntax_error(...).

just to clarify, this is the expected behavior? anything else more general?

jjtolton avatar Oct 26 '25 15:10 jjtolton

The elements of lists are of the form arg and thus constrained to priority 999. And thus an operator with priority 1000 is invalid no matter its associativity. In 6.3.3.1 Arguments:

           arg =  term ;
Abstract:  a      a
Priority:         999

UWN avatar Oct 26 '25 16:10 UWN

got it.

jjtolton avatar Nov 20 '25 23:11 jjtolton

3e6da5ad

J.J.'s robot

jjtolton avatar Nov 20 '25 23:11 jjtolton