From: Markus Triska Date: Fri, 30 Jun 2023 16:01:17 +0000 (+0200) Subject: constrain bracketing to operators with pertaining arity X-Git-Tag: v0.9.2~101^2~3 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=28065b0565ec9ec50b8802e5eddf7575533182a3;p=scryer-prolog.git constrain bracketing to operators with pertaining arity Example: ?- X = -->(a,b,c). X = -->(a,b,c). --- diff --git a/src/toplevel.pl b/src/toplevel.pl index ff463833..d61e324f 100644 --- a/src/toplevel.pl +++ b/src/toplevel.pl @@ -208,8 +208,9 @@ needs_bracketing(Value, Op) :- nonvar(Value), \+ integer(Value), functor(Value, F, Arity), - current_op(FPrec, _, F), + current_op(FPrec, FSpec, F), current_op(EqPrec, EqSpec, Op), + arity_specifier(Arity, FSpec), ( Arity =:= 0 -> true ; EqPrec < FPrec -> @@ -222,6 +223,10 @@ needs_bracketing(Value, Op) :- memberchk(EqSpec, [fx,xfx,yfx]) ). +arity_specifier(0, _). +arity_specifier(1, S) :- atom_chars(S, [_,_]). +arity_specifier(2, S) :- atom_chars(S, [_,_,_]). + write_goal(G, VarList, MaxDepth) :- ( G = (Var = Value) -> ( var(Value) ->