make double_quotes write option not dependent on double_quotes flag
This gives consistent results without depending on another flag.
This commit is contained in:
@@ -487,7 +487,6 @@ pub struct HCPrinter<'a, Outputter> {
|
|||||||
iter: StackfulPreOrderHeapIter<'a>,
|
iter: StackfulPreOrderHeapIter<'a>,
|
||||||
atom_tbl: &'a mut AtomTable,
|
atom_tbl: &'a mut AtomTable,
|
||||||
op_dir: &'a OpDir,
|
op_dir: &'a OpDir,
|
||||||
flags: MachineFlags,
|
|
||||||
state_stack: Vec<TokenOrRedirect>,
|
state_stack: Vec<TokenOrRedirect>,
|
||||||
toplevel_spec: Option<DirectedOp>,
|
toplevel_spec: Option<DirectedOp>,
|
||||||
last_item_idx: usize,
|
last_item_idx: usize,
|
||||||
@@ -555,7 +554,6 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
atom_tbl: &'a mut AtomTable,
|
atom_tbl: &'a mut AtomTable,
|
||||||
stack: &'a mut Stack,
|
stack: &'a mut Stack,
|
||||||
op_dir: &'a OpDir,
|
op_dir: &'a OpDir,
|
||||||
flags: MachineFlags,
|
|
||||||
output: Outputter,
|
output: Outputter,
|
||||||
cell: HeapCellValue,
|
cell: HeapCellValue,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -564,7 +562,6 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
iter: stackful_preorder_iter(heap, stack, cell),
|
iter: stackful_preorder_iter(heap, stack, cell),
|
||||||
atom_tbl,
|
atom_tbl,
|
||||||
op_dir,
|
op_dir,
|
||||||
flags,
|
|
||||||
state_stack: vec![],
|
state_stack: vec![],
|
||||||
toplevel_spec: None,
|
toplevel_spec: None,
|
||||||
last_item_idx: 0,
|
last_item_idx: 0,
|
||||||
@@ -1187,7 +1184,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
|||||||
|
|
||||||
let at_cdr = self.outputter.ends_with("|");
|
let at_cdr = self.outputter.ends_with("|");
|
||||||
|
|
||||||
if self.double_quotes && self.flags.double_quotes == DoubleQuotes::Chars {
|
if self.double_quotes {
|
||||||
if !at_cdr && !self.ignore_ops && end_cell.is_string_terminator(&self.iter.heap) {
|
if !at_cdr && !self.ignore_ops && end_cell.is_string_terminator(&self.iter.heap) {
|
||||||
self.remove_list_children(focus.value() as usize);
|
self.remove_list_children(focus.value() as usize);
|
||||||
return self.print_proper_string(focus.value() as usize, max_depth);
|
return self.print_proper_string(focus.value() as usize, max_depth);
|
||||||
|
|||||||
@@ -786,7 +786,6 @@ impl MachineState {
|
|||||||
&mut self.atom_tbl,
|
&mut self.atom_tbl,
|
||||||
&mut self.stack,
|
&mut self.stack,
|
||||||
op_dir,
|
op_dir,
|
||||||
self.flags,
|
|
||||||
PrinterOutputter::new(),
|
PrinterOutputter::new(),
|
||||||
term_to_be_printed,
|
term_to_be_printed,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ impl MockWAM {
|
|||||||
&mut self.machine_st.atom_tbl,
|
&mut self.machine_st.atom_tbl,
|
||||||
&mut self.machine_st.stack,
|
&mut self.machine_st.stack,
|
||||||
&self.op_dir,
|
&self.op_dir,
|
||||||
self.machine_st.flags,
|
|
||||||
PrinterOutputter::new(),
|
PrinterOutputter::new(),
|
||||||
heap_loc_as_cell!(term_write_result.heap_loc),
|
heap_loc_as_cell!(term_write_result.heap_loc),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -221,7 +221,13 @@ arity_specifier(0, _).
|
|||||||
arity_specifier(1, S) :- atom_chars(S, [_,_]).
|
arity_specifier(1, S) :- atom_chars(S, [_,_]).
|
||||||
arity_specifier(2, S) :- atom_chars(S, [_,_,_]).
|
arity_specifier(2, S) :- atom_chars(S, [_,_,_]).
|
||||||
|
|
||||||
|
double_quotes_option(DQ) :-
|
||||||
|
( current_prolog_flag(double_quotes, chars) -> DQ = true
|
||||||
|
; DQ = false
|
||||||
|
).
|
||||||
|
|
||||||
write_goal(G, VarList, MaxDepth) :-
|
write_goal(G, VarList, MaxDepth) :-
|
||||||
|
double_quotes_option(DQ),
|
||||||
( G = (Var = Value) ->
|
( G = (Var = Value) ->
|
||||||
( var(Value) ->
|
( var(Value) ->
|
||||||
select((Var = _), VarList, NewVarList)
|
select((Var = _), VarList, NewVarList)
|
||||||
@@ -231,16 +237,17 @@ write_goal(G, VarList, MaxDepth) :-
|
|||||||
write(' = '),
|
write(' = '),
|
||||||
( needs_bracketing(Value, =) ->
|
( needs_bracketing(Value, =) ->
|
||||||
write('('),
|
write('('),
|
||||||
write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(true)]),
|
write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(DQ)]),
|
||||||
write(')')
|
write(')')
|
||||||
; write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(true)])
|
; write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(DQ)])
|
||||||
)
|
)
|
||||||
; G == [] ->
|
; G == [] ->
|
||||||
write('true')
|
write('true')
|
||||||
; write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth), double_quotes(true)])
|
; write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth), double_quotes(DQ)])
|
||||||
).
|
).
|
||||||
|
|
||||||
write_last_goal(G, VarList, MaxDepth) :-
|
write_last_goal(G, VarList, MaxDepth) :-
|
||||||
|
double_quotes_option(DQ),
|
||||||
( G = (Var = Value) ->
|
( G = (Var = Value) ->
|
||||||
( var(Value) ->
|
( var(Value) ->
|
||||||
select((Var = _), VarList, NewVarList)
|
select((Var = _), VarList, NewVarList)
|
||||||
@@ -250,9 +257,9 @@ write_last_goal(G, VarList, MaxDepth) :-
|
|||||||
write(' = '),
|
write(' = '),
|
||||||
( needs_bracketing(Value, =) ->
|
( needs_bracketing(Value, =) ->
|
||||||
write('('),
|
write('('),
|
||||||
write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(true)]),
|
write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(DQ)]),
|
||||||
write(')')
|
write(')')
|
||||||
; write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(true)]),
|
; write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(DQ)]),
|
||||||
( trailing_period_is_ambiguous(Value) ->
|
( trailing_period_is_ambiguous(Value) ->
|
||||||
write(' ')
|
write(' ')
|
||||||
; true
|
; true
|
||||||
@@ -260,7 +267,7 @@ write_last_goal(G, VarList, MaxDepth) :-
|
|||||||
)
|
)
|
||||||
; G == [] ->
|
; G == [] ->
|
||||||
write('true')
|
write('true')
|
||||||
; write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth), double_quotes(true)])
|
; write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth), double_quotes(DQ)])
|
||||||
).
|
).
|
||||||
|
|
||||||
write_eq((G1, G2), VarList, MaxDepth) :-
|
write_eq((G1, G2), VarList, MaxDepth) :-
|
||||||
|
|||||||
Reference in New Issue
Block a user