s-webber / projog

Prolog programming for the Java platform.
Apache License 2.0
34 stars 9 forks source link

incorrect parsing of infix operators with xfy associativity #220

Closed s-webber closed 1 year ago

s-webber commented 1 year ago

Projog does not correctly parse infix operands that have xfy associativity. It parses them the same as infix operators that have yfx associativity.

Below are examples of how Projog currently parse yfx and xfy operators and how xfy operators should be parsed:

Current correct behaviour parsing +/2 (which has yfx associativity):

?- write_canonical((a+b+c)).
+(+(a, b), c)

Current incorrect behaviour when parsing ,/2 and ;/2 (which both have xfy associativity):

?- write_canonical((a,b,c)).
,(,(a, b), c)

?- write_canonical((a;b;c)).
;(;(a, b), c)

Expected behaviour when parsing ,/2 and ;/2 (which both have xfy associativity):

?- write_canonical((a,b,c)).
,(a, ,(b, c))

?- write_canonical((a;b;c)).
;(a, ;(b, c))