fix syntax regressions (#1198, #1164)

This commit is contained in:
Mark Thom
2022-01-12 23:55:40 -07:00
parent 39e28f1f2a
commit 3b8afce7c7
2 changed files with 19 additions and 19 deletions

View File

@@ -384,8 +384,8 @@ pub(crate) fn fetch_atom_op_spec(
spec: Option<OpDesc>,
op_dir: &OpDir,
) -> Option<OpDesc> {
fetch_op_spec_from_existing(name, 1, spec, op_dir)
.or_else(|| fetch_op_spec_from_existing(name, 2, spec, op_dir))
fetch_op_spec_from_existing(name, 2, spec, op_dir)
.or_else(|| fetch_op_spec_from_existing(name, 1, spec, op_dir))
}
pub(crate) fn fetch_op_spec_from_existing(
@@ -430,6 +430,9 @@ pub(crate) fn fetch_op_spec(name: Atom, arity: usize, op_dir: &OpDir) -> Option<
}
})
}
0 => {
fetch_atom_op_spec(name, None, op_dir)
}
_ => None,
}
}

View File

@@ -88,7 +88,7 @@ fn needs_bracketing(child_desc: OpDesc, op: &DirectedOp) -> bool {
true
} else if (is_postfix!(spec) || is_infix!(spec)) && !is_postfix!(child_desc.get_spec())
{
*cell == child_desc && child_desc.get_prec() == priority
*cell != child_desc && child_desc.get_prec() == priority
} else {
false
}
@@ -191,10 +191,10 @@ enum NumberFocus {
}
impl NumberFocus {
fn is_positive(&self) -> bool {
fn is_negative(&self) -> bool {
match self {
NumberFocus::Unfocused(n) => n.is_positive(),
NumberFocus::Denominator(r) | NumberFocus::Numerator(r) => **r > 0,
NumberFocus::Unfocused(n) => n.is_negative(),
NumberFocus::Denominator(r) | NumberFocus::Numerator(r) => **r < 0,
}
}
}
@@ -922,7 +922,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
fn print_number(&mut self, n: NumberFocus, op: &Option<DirectedOp>) {
let add_brackets = if let Some(op) = op {
op.is_negative_sign() && n.is_positive()
op.is_negative_sign() && !n.is_negative()
} else {
false
};
@@ -934,23 +934,20 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
match n {
NumberFocus::Unfocused(n) => match n {
Number::Float(fl) => {
if &fl == &OrderedFloat(0f64) {
push_space_if_amb!(self, "0.0", {
append_str!(self, "0.0");
});
} else {
let OrderedFloat(fl) = fl;
let output_str = format!("{0:<20?}", fl);
let OrderedFloat(fl) = fl;
let output_str = format!("{0:<20?}", fl);
push_space_if_amb!(self, &output_str, {
append_str!(self, &output_str.trim());
});
}
push_space_if_amb!(self, &output_str, {
append_str!(self, &output_str.trim());
});
}
Number::Rational(r) => {
self.print_rational(r, add_brackets);
return;
}
Number::Fixnum(n) => {
append_str!(self, &format!("{}", n.get_num()));
}
n => {
let output_str = format!("{}", n);
@@ -1427,7 +1424,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
}
}
(HeapCellValueTag::Fixnum, n) => {
append_str!(self, &format!("{}", n.get_num()));
self.print_number(NumberFocus::Unfocused(Number::Fixnum(n)), &op);
}
(HeapCellValueTag::F64, f) => {
self.print_number(NumberFocus::Unfocused(Number::Float(**f)), &op);