]> Repositorios git - scryer-prolog.git/commitdiff
print rationals that are integers as integers (#663)
authorMark Thom <[email protected]>
Thu, 10 Mar 2022 04:24:16 +0000 (21:24 -0700)
committerMark Thom <[email protected]>
Thu, 10 Mar 2022 04:24:16 +0000 (21:24 -0700)
Cargo.lock
Cargo.toml
src/heap_print.rs

index 4d699f115f6e257af98290249ec772d5455eb12f..dad5a5b45c962d71ead16ab6082188307defe856 100644 (file)
@@ -1348,9 +1348,9 @@ dependencies = [
 
 [[package]]
 name = "rug"
-version = "1.13.0"
+version = "1.15.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee0c6e98de59509e62e09f3456b23cebb75dad21928882016f169bb628843459"
+checksum = "6ac804305677221f4c82469fd7eb8bfe00dd01420aa191197cb87d738520feef"
 dependencies = [
  "az",
  "gmp-mpfr-sys",
index 8e81a947f99d13054d8023ffe7f534e775416aa9..193d6ce6dff81635de2715d45f5c1ff3ca69b260 100644 (file)
@@ -49,7 +49,7 @@ num-rug-adapter = { optional = true, path = "./crates/num-rug-adapter" }
 ordered-float = "2.1.1"
 phf = { version = "0.9",  features = ["macros"] }
 ref_thread_local = "0.0.0"
-rug = { version = "1.12.0", optional = true }
+rug = { version = "1.15.0", optional = true }
 rustyline = "9.0.0"
 ring = "0.16.13"
 ripemd160 = "0.8.0"
index b7ee855220c1c8b31b017ded815ee29d4a3703da..18d2d4276f773460fb4738404bfdc1869cc38996 100644 (file)
@@ -961,8 +961,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
                     });
                 }
                 Number::Rational(r) => {
-                    self.print_rational(r, add_brackets);
-                    return;
+                    self.print_rational(r);
                 }
                 n => {
                     let output_str = format!("{}", n);
@@ -993,11 +992,17 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
         }
     }
 
-    fn print_rational(&mut self, r: TypedArenaPtr<Rational>, add_brackets: bool) {
+    fn print_rational(&mut self, r: TypedArenaPtr<Rational>) {
         match self.op_dir.get(&(atom!("rdiv"), Fixity::In)) {
             Some(op_desc) => {
-                if add_brackets {
-                    self.state_stack.push(TokenOrRedirect::Close);
+                if r.is_integer() {
+                    let output_str = format!("{}", r);
+
+                    push_space_if_amb!(self, &output_str, {
+                        append_str!(self, &output_str);
+                    });
+
+                    return;
                 }
 
                 let rdiv_ct = atom!("rdiv");