ignore single line comments after end token read

This commit is contained in:
Mark Thom
2019-09-25 22:40:31 -06:00
parent e108b844bd
commit 737acb7cde
8 changed files with 36 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "scryer-prolog"
version = "0.8.92"
version = "0.8.93"
authors = ["Mark Thom <markjordanthom@gmail.com>"]
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"

View 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

View 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')]),

View 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.

View 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

View 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 => {

View 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,
}
}

View 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]).");