add conditional bracketing to equations printed by toplevel
This commit is contained in:
@@ -461,7 +461,7 @@ pub(crate) trait CallPolicy: Any {
|
|||||||
let b = machine_st.b - 1;
|
let b = machine_st.b - 1;
|
||||||
let n = machine_st.or_stack[b].num_args();
|
let n = machine_st.or_stack[b].num_args();
|
||||||
|
|
||||||
for i in 1..n + 1 {
|
for i in 1 .. n + 1 {
|
||||||
machine_st.registers[i] = machine_st.or_stack[b][i].clone();
|
machine_st.registers[i] = machine_st.or_stack[b][i].clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,11 +44,27 @@
|
|||||||
; write('false.'), nl
|
; write('false.'), nl
|
||||||
).
|
).
|
||||||
|
|
||||||
|
'$needs_bracketing'(Value, Op) :-
|
||||||
|
catch((functor(Value, F, _),
|
||||||
|
current_op(EqPrec, EqSpec, Op),
|
||||||
|
current_op(FPrec, _, F)),
|
||||||
|
_,
|
||||||
|
false),
|
||||||
|
( EqPrec < FPrec -> true
|
||||||
|
; EqPrec == FPrec,
|
||||||
|
memberchk(EqSpec, [fx,xfx,yfx])
|
||||||
|
).
|
||||||
|
|
||||||
'$write_goal'(G, VarList) :-
|
'$write_goal'(G, VarList) :-
|
||||||
( G = (Var = Value) ->
|
( G = (Var = Value) ->
|
||||||
write(Var),
|
write(Var),
|
||||||
write(' = '),
|
write(' = '),
|
||||||
write_term(Value, [quoted(true), variable_names(VarList)])
|
( '$needs_bracketing'(Value, (=)) ->
|
||||||
|
write('('),
|
||||||
|
write_term(Value, [quoted(true), variable_names(VarList)]),
|
||||||
|
write(')')
|
||||||
|
; write_term(Value, [quoted(true), variable_names(VarList)])
|
||||||
|
)
|
||||||
; G == [] ->
|
; G == [] ->
|
||||||
write('true')
|
write('true')
|
||||||
; write_term(G, [quoted(true), variable_names(VarList)])
|
; write_term(G, [quoted(true), variable_names(VarList)])
|
||||||
|
|||||||
Reference in New Issue
Block a user