Merge pull request #1852 from triska/needs_bracketing
Improvements to needs_bracketing/2
This commit is contained in:
@@ -208,20 +208,19 @@ needs_bracketing(Value, Op) :-
|
|||||||
nonvar(Value),
|
nonvar(Value),
|
||||||
\+ integer(Value),
|
\+ integer(Value),
|
||||||
functor(Value, F, Arity),
|
functor(Value, F, Arity),
|
||||||
current_op(FPrec, _, F),
|
current_op(FPrec, FSpec, F),
|
||||||
current_op(EqPrec, EqSpec, Op),
|
current_op(EqPrec, EqSpec, Op),
|
||||||
( Arity =:= 0 ->
|
arity_specifier(Arity, FSpec),
|
||||||
true
|
( Arity =:= 0
|
||||||
; EqPrec < FPrec ->
|
; EqPrec < FPrec
|
||||||
true
|
; EqPrec =:= FPrec,
|
||||||
; FPrec > 0, F == Value, graphic_token_char(F) ->
|
member(EqSpec, [fx,xfx,yfx])
|
||||||
true
|
|
||||||
; F \== '.', '$quoted_token'(F) ->
|
|
||||||
true
|
|
||||||
; EqPrec == FPrec,
|
|
||||||
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) :-
|
write_goal(G, VarList, MaxDepth) :-
|
||||||
( G = (Var = Value) ->
|
( G = (Var = Value) ->
|
||||||
( var(Value) ->
|
( var(Value) ->
|
||||||
|
|||||||
Reference in New Issue
Block a user