This commit is contained in:
Mark Thom
2019-03-31 22:30:42 -06:00
parent df5e538dc6
commit 2240418a25
6 changed files with 32 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "scryer-prolog"
version = "0.8.33"
version = "0.8.34"
authors = ["Mark Thom <markjordanthom@gmail.com>"]
repository = "https://github.com/mthom/scryer-prolog"
description = "A modern Prolog implementation written mostly in Rust."
@@ -14,7 +14,7 @@ cfg-if = "0.1.7"
downcast = "0.10.0"
num = "0.2"
ordered-float = "0.5.0"
prolog_parser = "0.8.10"
prolog_parser = "0.8.11"
readline_rs_compat = { version = "0.1.7", optional = true }
ref_thread_local = "0.0.0"

View File

@@ -408,7 +408,8 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<TermMarker>
},
&InlinedClauseType::IsInteger(..) =>
match terms[0].as_ref() {
&Term::Constant(_, Constant::Number(Number::Integer(_))) => {
&Term::Constant(_, Constant::CharCode(_))
| &Term::Constant(_, Constant::Number(Number::Integer(_))) => {
code.push(succeed!());
},
&Term::Var(ref vr, ref name) => {

View File

@@ -536,16 +536,15 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter>
fn print_atom(&mut self, atom: &ClauseName) {
push_space_if_amb!(self, atom.as_str(), {
match atom.as_str() {
"''" => self.append_str("''"),
s => self.print_op_addendum(s)
}
self.print_op_addendum(atom.as_str());
});
}
fn print_op_addendum(&mut self, atom: &str) {
if !self.quoted || non_quoted_token(atom.chars()) {
self.append_str(atom);
} else if atom == "''" {
self.append_str("''");
} else {
if self.quoted {
self.push_char('\'');

View File

@@ -1,16 +1,17 @@
:- op(400, yfx, /).
:- module(builtins, [(=)/2, (\=)/2, (\+)/1, (+)/1, (+)/2, (**)/2,
(*)/2, (-)/1, (-)/2, (/)/2, (/\)/2, (\/)/2, (is)/2, (xor)/2,
(div)/2, (//)/2, (rdiv)/2, (<<)/2, (>>)/2, (mod)/2, (rem)/2,
(>)/2, (<)/2, (=\=)/2, (=:=)/2, (>=)/2, (=<)/2, (,)/2, (->)/2,
(;)/2, (=..)/2, (==)/2, (\==)/2, (@=<)/2, (@>=)/2, (@<)/2,
(@>)/2, (=@=)/2, (\=@=)/2, (:)/2, abolish/1, asserta/1,
assertz/1, bagof/3, bb_b_put/2, bb_get/2, bb_put/2,
call_cleanup/2, call_with_inference_limit/3, catch/3,
clause/2, current_predicate/1, current_prolog_flag/2,
expand_goal/2, expand_term/2, findall/3, findall/4, halt/0,
once/1, op/3, repeat/0, retract/1, set_prolog_flag/2, setof/3,
:- module(builtins, [(=)/2, (\=)/2, (\+)/1, (^)/2, (\)/1, (+)/1,
(+)/2, (**)/2, (*)/2, (-)/1, (-)/2, (/)/2, (/\)/2, (\/)/2,
(is)/2, (xor)/2, (div)/2, (//)/2, (rdiv)/2, (<<)/2, (>>)/2,
(mod)/2, (rem)/2, (>)/2, (<)/2, (=\=)/2, (=:=)/2, (>=)/2,
(=<)/2, (,)/2, (->)/2, (;)/2, (=..)/2, (==)/2, (\==)/2,
(@=<)/2, (@>=)/2, (@<)/2, (@>)/2, (=@=)/2, (\=@=)/2, (:)/2,
abolish/1, asserta/1, assertz/1, bagof/3, bb_b_put/2,
bb_get/2, bb_put/2, call_cleanup/2,
call_with_inference_limit/3, catch/3, clause/2,
current_predicate/1, current_prolog_flag/2, expand_goal/2,
expand_term/2, findall/3, findall/4, halt/0, once/1, op/3,
repeat/0, retract/1, set_prolog_flag/2, setof/3,
setup_call_cleanup/3, term_variables/2, throw/1, true/0,
false/0, write/1, write_canonical/1, writeq/1, write_term/2]).
@@ -33,11 +34,11 @@ expand_op_list([Op | OtherOps], Pred, Spec, [(:- op(Pred, Spec, Op)) | OtherResu
:- op(700, xfx, is).
:- op(500, yfx, [+, -]).
:- op(400, yfx, *).
:- op(200, xfy, **).
:- op(200, xfy, [**, ^]).
:- op(500, yfx, [/\, \/, xor]).
:- op(400, yfx, [div, //, rdiv]).
:- op(400, yfx, [<<, >>, mod, rem]).
:- op(200, fy, [+, -]).
:- op(200, fy, [+, -, \]).
% arithmetic comparison operators.
:- op(700, xfx, [>, <, =\=, =:=, >=, =<]).

View File

@@ -1,10 +1,10 @@
:- module(dcgs, [(-->)/2, phrase/2, phrase/3]).
:- op(1200, xfx, -->).
:- module(dcgs, [phrase/2, phrase/3]).
:- use_module(library(lists), [append/3]).
:- use_module(library(terms)).
:- op(1200, xfx, -->).
phrase(G, G) :-
nonvar(G), G = [_|_], !.
phrase(G, Ls0) :-

View File

@@ -14,7 +14,7 @@ use prolog::machine::or_stack::*;
use prolog::machine::machine_errors::*;
use prolog::machine::machine_indices::*;
use prolog::machine::machine_state::*;
use prolog::num::{Integer, Signed, ToPrimitive, Zero};
use prolog::num::{Integer, Signed, ToPrimitive, One, Zero};
use prolog::num::bigint::{BigInt, BigUint};
use prolog::num::rational::Ratio;
@@ -1913,6 +1913,13 @@ impl MachineState {
match d {
Addr::Con(Constant::Number(Number::Integer(_))) => self.p += 1,
Addr::Con(Constant::CharCode(_)) => self.p += 1,
Addr::Con(Constant::Number(Number::Rational(r))) =>
if r.denom() == &BigInt::one() {
self.p += 1;
} else {
self.fail = true;
},
_ => self.fail = true
};
},