]> Repositorios git - scryer-prolog.git/commitdiff
ignore single line comments after end token read
authorMark Thom <[email protected]>
Thu, 26 Sep 2019 04:40:31 +0000 (22:40 -0600)
committerMark Thom <[email protected]>
Thu, 26 Sep 2019 04:40:31 +0000 (22:40 -0600)
Cargo.toml
src/prolog/examples/domain.pl
src/prolog/examples/expert_system.pl
src/prolog/examples/minatotask.pl
src/prolog/examples/plres.pl
src/prolog/machine/machine_state.rs
src/prolog/machine/machine_state_impl.rs
src/tests.rs

index 28498ab1e2426061ca2312b2788c902f0137e63e..ec8c2b85fec40849166aa58980ea5959404e431c 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "scryer-prolog"
-version = "0.8.92"
+version = "0.8.93"
 authors = ["Mark Thom <[email protected]>"]
 repository = "https://github.com/mthom/scryer-prolog"
 description = "A modern Prolog implementation written mostly in Rust."
@@ -15,7 +15,7 @@ dirs = "2.0.2"
 downcast = "0.10.0"
 indexmap = "1.0.2"
 ordered-float = "0.5.0"
-prolog_parser = "0.8.28"
+prolog_parser = "0.8.29"
 readline_rs_compat = { version = "0.1.9", optional = true }
 ref_thread_local = "0.0.0"
 rug = "1.4.0"
index cfada79f51c82f79f0d46995d2b17c5cbfadf607..f1fadad921d7d5475abe4604242495190c9a457f 100644 (file)
@@ -4,8 +4,8 @@ https://sicstus.sics.se/sicstus/docs/3.7.1/html/sicstus_17.html
 
 :- module(domain, [domain/2]).
 
-:- use_module(library(atts)).
-:- use_module(library(ordsets), [
+:- use_module('src/prolog/lib/atts').
+:- use_module('src/prolog/lib/ordsets', [
         ord_intersection/3,
         ord_intersect/2,
         list_to_ord_set/2
index 43ba9bd76a53d1d5bf231052d791a85f2e1b9f28..55b5d28712e65ba6dc339160d91ad9256b649dfb 100644 (file)
@@ -1,5 +1,5 @@
-:- use_module(library(dcgs)).
-:- use_module(library(reif)).
+:- use_module('src/prolog/lib/dcgs').
+:- use_module('src/prolog/lib/reif').
 
 animals([animal(dog, [is_true('has fur'), is_true('says woof')]),
          animal(cat, [is_true('has fur'), is_true('says meow')]),
index fd1a4233a1ae033178ce9103814d9a0a5fb7abd2..2d0d4ff9c563604b0aff43f62971b8ce175cddff 100644 (file)
@@ -60,9 +60,9 @@
 
 :- module(zdd, [variables_set_zdd/2]).
 
-:- use_module(library(atts)).
-:- use_module(library(dcgs)).
-:- use_module(library(lists)).
+:- use_module('src/prolog/lib/atts').
+:- use_module('src/prolog/lib/dcgs').
+:- use_module('src/prolog/lib/lists').
 
 :- attribute zdd_vs/2.
 
index a19ca5a73a9dc7f6c86f5f6a70fc7020edbab801..3ccfc4090961fd7381da2db352666bf282e3bbe6 100644 (file)
@@ -29,9 +29,9 @@
 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
-:- use_module(library(dcgs)).
-:- use_module(library(dif)).
-:- use_module(library(lists)).
+:- use_module('src/prolog/lib/dcgs').
+:- use_module('src/prolog/lib/dif').
+:- use_module('src/prolog/lib/lists').
 
 pl_resolution(Clauses0, Chain) :-
         maplist(sort, Clauses0, Clauses), % remove duplicates
index 166e2c43e36561aac9d11d28f51e4d9c3964eac0..d5f96d70a47260200292ce5b751c526ea765af46 100644 (file)
@@ -692,7 +692,10 @@ pub(crate) trait CallPolicy: Any {
                 return_from_clause!(machine_st.last_call, machine_st)
             }
             &BuiltInClauseType::Eq => {
-                machine_st.fail = machine_st.eq_test();
+                let a1 = machine_st[temp_v!(1)].clone();
+                let a2 = machine_st[temp_v!(2)].clone();
+
+                machine_st.fail = machine_st.eq_test(a1, a2);
                 return_from_clause!(machine_st.last_call, machine_st)
             }
             &BuiltInClauseType::Ground => {
index 1df1b7bf8c1241df5c6c8adc1656e0ad659bcea7..ca38167253484b1f68baafc4b1033981d8ca5834 100644 (file)
@@ -552,7 +552,7 @@ impl MachineState {
                         self.fail = true;
                     }
                     (Addr::Lis(a1), Addr::Con(Constant::String(ref mut s)))
-                    | (Addr::Con(Constant::String(ref mut s)), Addr::Lis(a1)) => {
+                  | (Addr::Con(Constant::String(ref mut s)), Addr::Lis(a1)) => {
                         if match self.flags.double_quotes {
                             DoubleQuotes::Chars => self.deconstruct_chars(s, a1, &mut pdl),
                             DoubleQuotes::Codes => self.deconstruct_codes(s, a1, &mut pdl),
@@ -564,7 +564,7 @@ impl MachineState {
                         self.fail = true;
                     }
                     (Addr::Con(Constant::EmptyList), Addr::Con(Constant::String(ref s)))
-                    | (Addr::Con(Constant::String(ref s)), Addr::Con(Constant::EmptyList))
+                  | (Addr::Con(Constant::String(ref s)), Addr::Con(Constant::EmptyList))
                         if !self.flags.double_quotes.is_atom() =>
                     {
                         if s.is_expandable() && s.is_empty() {
@@ -852,11 +852,8 @@ impl MachineState {
             Addr::Con(Constant::String(ref mut s)) => {
                 self.fail = self.write_constant_to_string(s, c)
             }
-            Addr::Con(c1) => {
-                if c1 != c {
-                    self.fail = true;
-                }
-            }
+            Addr::Con(c1) =>
+                self.fail = self.eq_test(Addr::Con(c), Addr::Con(c1)),
             Addr::Lis(l) => self.unify(Addr::Lis(l), Addr::Con(c)),
             addr => {
                 if let Some(r) = addr.as_var() {
@@ -2266,25 +2263,29 @@ impl MachineState {
     }
 
     // returns true on failure.
-    pub(super) fn eq_test(&self) -> bool {
-        let a1 = self[temp_v!(1)].clone();
-        let a2 = self[temp_v!(2)].clone();
-
+    pub(super) fn eq_test(&self, a1: Addr, a2: Addr) -> bool {
         let mut iter = self.zipped_acyclic_pre_order_iter(a1, a2);
 
         while let Some((v1, v2)) = iter.next() {
             match (v1, v2) {
-                (HeapCellValue::NamedStr(ar1, n1, _), HeapCellValue::NamedStr(ar2, n2, _)) => {
+                (HeapCellValue::NamedStr(ar1, n1, _), HeapCellValue::NamedStr(ar2, n2, _)) =>
                     if ar1 != ar2 || n1 != n2 {
                         return true;
-                    }
-                }
-                (HeapCellValue::Addr(Addr::Lis(_)), HeapCellValue::Addr(Addr::Lis(_))) => continue,
-                (HeapCellValue::Addr(a1), HeapCellValue::Addr(a2)) => {
+                    },
+                (HeapCellValue::Addr(Addr::Lis(_)), HeapCellValue::Addr(Addr::Lis(_))) =>
+                    continue,
+                (HeapCellValue::Addr(Addr::Con(Constant::EmptyList)),
+                 HeapCellValue::Addr(Addr::Con(Constant::String(s))))
+              | (HeapCellValue::Addr(Addr::Con(Constant::String(s))),
+                 HeapCellValue::Addr(Addr::Con(Constant::EmptyList))) =>
+                    return match self.flags.double_quotes {
+                        DoubleQuotes::Atom => true,
+                        _ => !s.is_empty()
+                    },
+                (HeapCellValue::Addr(a1), HeapCellValue::Addr(a2)) =>
                     if a1 != a2 {
                         return true;
-                    }
-                }
+                    },                
                 _ => return true,
             }
         }
index ef247436178b0367544d07e42ca7457e8930e358..d8857b38e1f7320e5ba1f45af85748c84f55b5b0 100644 (file)
@@ -3068,7 +3068,7 @@ fn test_queries_on_string_lists() {
 
     // double_quotes is chars by default.
     assert_prolog_success!(&mut wam, "variant(\"\", []).");
-    assert_prolog_failure!(&mut wam, "\"\" == [].");
+    assert_prolog_success!(&mut wam, "\"\" == [].");
     assert_prolog_failure!(&mut wam, "\"abc\" == [].");
     assert_prolog_success!(&mut wam, "variant(\"abc\", ['a', 'b', 'c']).");
     assert_prolog_success!(&mut wam, "variant(\"abc\", ['a', 'b', c]).");