]> Repositorios git - scryer-prolog.git/commitdiff
unify matching strings with different cursors.
authorMark Thom <[email protected]>
Mon, 27 Aug 2018 02:50:12 +0000 (20:50 -0600)
committerMark Thom <[email protected]>
Mon, 27 Aug 2018 02:50:12 +0000 (20:50 -0600)
src/prolog/machine/machine_state_impl.rs
src/prolog/string_list.rs

index ee68a2e57169519aa6b9f4fdb133b14ac5360ddd..1bd939dbc7f76b607aa6acf7a4dd2e0bb97d41ac 100644 (file)
@@ -214,6 +214,24 @@ impl MachineState {
                         pdl.push(Addr::HeapCell(a1 + 1));
                         pdl.push(Addr::HeapCell(a2 + 1));
                     },
+                    (Addr::Con(Constant::String(ref s1)), Addr::Con(Constant::String(ref s2))) => {
+                        if let Some(c1) = s1.head() {
+                            if let Some(c2) = s2.head() {
+                                if c1 == c2 {
+                                    pdl.push(Addr::Con(Constant::String(s1.tail())));
+                                    pdl.push(Addr::Con(Constant::String(s2.tail())));
+                                    
+                                    continue;
+                                }
+                            }
+                        } else {
+                            if s2.head().is_none() {
+                                continue;
+                            }
+                        }
+
+                        self.fail = true;
+                    },
                     (Addr::Con(ref c1), Addr::Con(ref c2)) => 
                         if c1 != c2 {
                             self.fail = true;
index d4f8e35ebd2f7deb4c71eb89bb29d366db4f7338..b467676583978723d3fdf90a2770ec87bfe37f53 100644 (file)
@@ -46,7 +46,7 @@ impl Ord for StringList {
 impl PartialEq for StringList {
     fn eq(&self, other: &Self) -> bool
     {
-        self.body == other.body
+        self.body == other.body && self.cursor == other.cursor && self.expandable == other.expandable
     }
 }