]> Repositorios git - scryer-prolog.git/commitdiff
add structural tests for partial strings, rename ast.rs
authorMark Thom <[email protected]>
Wed, 5 Sep 2018 03:20:45 +0000 (21:20 -0600)
committerMark Thom <[email protected]>
Wed, 5 Sep 2018 03:20:45 +0000 (21:20 -0600)
27 files changed:
Cargo.lock
src/main.rs
src/prolog/allocator.rs
src/prolog/and_stack.rs
src/prolog/arithmetic.rs
src/prolog/codegen.rs
src/prolog/compile.rs
src/prolog/copier.rs
src/prolog/debray_allocator.rs
src/prolog/fixtures.rs
src/prolog/heap_iter.rs
src/prolog/heap_print.rs
src/prolog/indexing.rs
src/prolog/instructions.rs [moved from src/prolog/ast.rs with 100% similarity]
src/prolog/io.rs
src/prolog/iterators.rs
src/prolog/machine/machine_errors.rs
src/prolog/machine/machine_state.rs
src/prolog/machine/machine_state_impl.rs
src/prolog/machine/mod.rs
src/prolog/machine/system_calls.rs
src/prolog/mod.rs
src/prolog/or_stack.rs
src/prolog/read.rs
src/prolog/targets.rs
src/prolog/toplevel.rs
src/tests.rs

index a33c62b14f91a3b3756debc38968bd5301f7eac7..6fe939cef2c5e1f81f7b664d00f5efced46381c0 100644 (file)
@@ -86,7 +86,8 @@ dependencies = [
 
 [[package]]
 name = "prolog_parser"
-version = "0.7.9"
+version = "0.7.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -112,7 +113,7 @@ dependencies = [
  "downcast 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "prolog_parser 0.7.9",
+ "prolog_parser 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -151,6 +152,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070"
 "checksum num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "630de1ef5cc79d0cdd78b7e33b81f083cbfe90de0f4b2b2f07f905867c70e9fe"
 "checksum ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58d25b6c0e47b20d05226d288ff434940296e7e2f8b877975da32f862152241f"
+"checksum prolog_parser 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "277adc8aef82e87336a642a9bbd480cac9550e5ec63c99465eed7cbc7c165808"
 "checksum redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "ab105df655884ede59d45b7070c8a65002d921461ee813a024558ca16030eea0"
 "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
 "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
index 2c53b5ffe89afee462f5631d4e682ea587188b45..3c880a6299234fbc9821055d0cb88c75587e7426 100644 (file)
@@ -2,7 +2,7 @@
 #[macro_use] extern crate prolog_parser;
 extern crate termion;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 
 mod prolog;
 
index cf6456813a52e6b681316eb3eb64234d8a4e6654..a6c74dd5033b3a8f226bdb0d9fe7fa1d0141756c 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::fixtures::*;
 use prolog::targets::*;
 
index fdf22c2968b732f30f206253eecd7426e2acc786..e012b631793b877178b5f0d0ecab3ea2a868640b 100644 (file)
@@ -1,4 +1,4 @@
-use prolog::ast::*;
+use prolog::instructions::*;
 
 use std::ops::{Index, IndexMut};
 use std::vec::Vec;
index b91df8f07d2b4b054778beedfb0efe869262e85d..a3cdc5f64f0c09698ba9e82db4ffe1e973eceb52 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use std::cell::Cell;
 use std::cmp::{min, max};
 use std::rc::Rc;
index becf6e714f02b44e2795006f1dd26874739bbfba..47ee1b6ea0a744417ac850cb7bd2692485a0d366 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::allocator::*;
 use prolog::arithmetic::*;
 use prolog::fixtures::*;
index ca151441c56441971017f5b7a5e0c721a0030433..0b9330c0f77ce4318cf08303b7be6a89a041c3cd 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::debray_allocator::*;
 use prolog::codegen::*;
 use prolog::machine::*;
index 6ac18b6ae3f8d47e4ca7074acce21557dc249142..ffb689a34f4e7130c50c9b9c0a45612b2bb7b307 100644 (file)
@@ -1,5 +1,5 @@
-use prolog::ast::*;
 use prolog::and_stack::*;
+use prolog::instructions::*;
 
 use std::ops::IndexMut;
 
index 88a40a02d0f36f8f429aaf848f8107555d2142be..549cbb335b2a4e4eed46b440f05902f279c75367 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::allocator::*;
 use prolog::targets::*;
 
index c2ee7e3fae00bea968d3aa37d108ceedf953e09f..ffdf8da5726738bae395c3ad3f4eea2437f896f9 100644 (file)
@@ -1,8 +1,8 @@
 use prolog_parser::ast::*;
 
+use prolog::instructions::*;
 use prolog::iterators::*;
 
-use prolog::ast::*;
 use std::cell::Cell;
 use std::collections::{BTreeMap, HashMap};
 use std::collections::btree_map::{IntoIter, IterMut, Values};
index 5ce1c54344a9dc670c04684a1b18c0377cd212b9..1428edf32b971df778c12582bd4e70335940705c 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::machine::machine_state::*;
 
 use std::collections::HashSet;
index 4af86934a152aec86179a0377238f3feae8bb6a4..c4750c0d302cbf5cf6ab9b75aacb5dd6f6f4a795 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::machine::machine_state::*;
 use prolog::num::*;
 use prolog::heap_iter::*;
index 2da720587a8c76ce25a57a8f1e74cb5f7bd9391a..151a5fcf846cff5206c926498a0a6af34d27c1b2 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use std::collections::{HashMap, VecDeque};
 use std::hash::Hash;
 use std::rc::Rc;
@@ -217,7 +217,6 @@ impl CodeOffsets {
             IntIndex::Internal(_) => prelude_len - lst_offset + 1
         }
     }
-
     
     pub fn add_indices(self, code: &mut Code, mut code_body: Code)
     {
similarity index 100%
rename from src/prolog/ast.rs
rename to src/prolog/instructions.rs
index f1ff550e9e9c5397fe88921b6a575e5cea9a6c95..6f7671c6a4cb245c408b3a04ae8a42c9e593b79c 100644 (file)
@@ -1,4 +1,4 @@
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::heap_print::*;
 use prolog::machine::*;
 
index 1eff90f90f69acb22871cf5136456c86436b9900..6b2c83b1029c496c90540be52dd2ce86b284ed37 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use std::cell::Cell;
 use std::collections::VecDeque;
 use std::iter::*;
index d5907b7f3761f72067f32fc66d5a65541b86f01f..066dde16cddf57aea21e3204f56a67b28b060477 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::machine::machine_state::*;
 use prolog::num::bigint::BigInt;
 
index 7432e5997cdf99c59b0e4e245e0633cf90e81627..fe6c928767e9d7a9fef1c80334ac616308740097 100644 (file)
@@ -1,7 +1,7 @@
 use prolog_parser::ast::*;
 use prolog_parser::tabled_rc::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::and_stack::*;
 use prolog::copier::*;
 use prolog::heap_print::*;
index 942b491ccfb53dc7d16764e86a209574d40bf6d2..4791f5126f944575bfe93463bccd29db6c657e0f 100644 (file)
@@ -1,7 +1,7 @@
 use prolog_parser::ast::*;
 use prolog_parser::string_list::StringList;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::and_stack::*;
 use prolog::copier::*;
 use prolog::heap_iter::*;
@@ -1528,10 +1528,22 @@ impl MachineState {
                     return Ordering::Greater,
                 (HeapCellValue::Addr(Addr::Con(Constant::String(_))),
                  HeapCellValue::Addr(Addr::Con(Constant::Number(_)))) =>
-                    return Ordering::Greater,
+                    return Ordering::Greater,                
                 (HeapCellValue::Addr(Addr::Con(Constant::String(s1))),
                  HeapCellValue::Addr(Addr::Con(Constant::String(s2)))) =>
-                    return s1.cmp(&s2),
+                    return if s1.is_expandable() {
+                        if s2.is_expandable() {
+                            s1.cmp(&s2)
+                        } else {
+                            Ordering::Greater
+                        }
+                    } else {
+                        if s2.is_expandable() {
+                            Ordering::Less
+                        } else {
+                            s1.cmp(&s2)
+                        }
+                    },
                 (HeapCellValue::Addr(Addr::Con(Constant::String(_))), _) =>
                     return Ordering::Less,
                 (HeapCellValue::Addr(Addr::Con(Constant::Atom(..))),
index 7cf011fe6681c5c30c3180326673496cdabf648d..8d7e1ef9ceee4fc8527d87fc57867e7c9a9fc25b 100644 (file)
@@ -1,7 +1,7 @@
 use prolog_parser::ast::*;
 use prolog_parser::tabled_rc::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::compile::*;
 use prolog::heap_print::*;
 
index 451c99e6b517359bf38e77de8c95357cb53d710a..acb3af3480a2a55360eaf0d4eba055964b247f64 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::machine::machine_errors::*;
 use prolog::machine::machine_state::*;
 use prolog::num::{ToPrimitive, Zero};
index ffc4de438a2da0a8453b9a772b6692425c3d643c..1e137abbe7f5dc97c556360bdd3e1f5c4197982a 100644 (file)
@@ -2,7 +2,7 @@ extern crate num;
 extern crate ordered_float;
 extern crate prolog_parser;
 
-#[macro_use] pub mod ast;
+#[macro_use] pub mod instructions;
 pub mod and_stack;
 #[macro_use] pub mod macros;
 #[macro_use] pub mod allocator;
index d32c490f51d75049ef93270225eaf7a016afd45d..6fda0971c9b4899f3cc902d54dbaf3f5140750be 100644 (file)
@@ -1,4 +1,4 @@
-use prolog::ast::*;
+use prolog::instructions::*;
 
 use std::ops::{Index, IndexMut};
 use std::vec::Vec;
index 1f4bd4eb0156cc2badb3df50973095655b6aa603..ffba2635a02c850fc62240e5044acac2a875ae8e 100644 (file)
@@ -1,7 +1,7 @@
 use prolog_parser::ast::*;
 use prolog_parser::parser::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::iterators::*;
 use prolog::machine::machine_state::*;
 
index 9eaa2a34dd214351a7d35f093b9a4cc5e2b385e1..094e0f4063108ec30e603cd080e7f79ec72d46f1 100644 (file)
@@ -1,6 +1,6 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::iterators::*;
 
 pub trait CompilationTarget<'a> {
index 266b153f9b525ec33088adc31558edff0bf567c7..aaef8bfa108421d462f41a22ab0750b9e74c341e 100644 (file)
@@ -2,7 +2,7 @@ use prolog_parser::ast::*;
 use prolog_parser::parser::*;
 use prolog_parser::tabled_rc::*;
 
-use prolog::ast::*;
+use prolog::instructions::*;
 use prolog::iterators::*;
 use prolog::machine::*;
 use prolog::num::*;
index aef15b7e972c9e20dccee98c870e0e2657e3ed6d..ea8446599e11b619c593167b305f9aecb6ab0693 100644 (file)
@@ -1,7 +1,7 @@
 use prolog_parser::ast::*;
 
-use prolog::ast::*;
 use prolog::heap_print::*;
+use prolog::instructions::*;
 use prolog::compile::*;
 use prolog::machine::*;
 
@@ -1936,4 +1936,7 @@ fn test_queries_on_string_lists()
     assert_prolog_failure!(&mut wam, "?- partial_string(\"abc\", X), partial_string(\"ababc\", Y), Y = [a,b|Z],
                                          X == Z.");
 
+    assert_prolog_success!(&mut wam, "?- partial_string(\"abc\", X), X @> \"abc\".");
+    assert_prolog_failure!(&mut wam, "?- partial_string(\"abc\", X), X \\=@= \"abc\".");
+    assert_prolog_failure!(&mut wam, "?- partial_string(\"abc\", X), X @< \"abc\".");
 }