From: Mark Thom Date: Mon, 1 Apr 2019 04:30:42 +0000 (-0600) Subject: re: #75, #52 X-Git-Tag: v0.8.110~132 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=2240418a25e606741214500a3f84653ef047e823;p=scryer-prolog.git re: #75, #52 --- diff --git a/Cargo.toml b/Cargo.toml index fc4b56d5..d1610c55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scryer-prolog" -version = "0.8.33" +version = "0.8.34" authors = ["Mark Thom "] 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" diff --git a/src/prolog/codegen.rs b/src/prolog/codegen.rs index 462cda0f..f05e8d58 100644 --- a/src/prolog/codegen.rs +++ b/src/prolog/codegen.rs @@ -408,7 +408,8 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator }, &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) => { diff --git a/src/prolog/heap_print.rs b/src/prolog/heap_print.rs index 38429884..c7ef60ed 100644 --- a/src/prolog/heap_print.rs +++ b/src/prolog/heap_print.rs @@ -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('\''); diff --git a/src/prolog/lib/builtins.pl b/src/prolog/lib/builtins.pl index fb3933b8..3639baf7 100644 --- a/src/prolog/lib/builtins.pl +++ b/src/prolog/lib/builtins.pl @@ -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, [>, <, =\=, =:=, >=, =<]). diff --git a/src/prolog/lib/dcgs.pl b/src/prolog/lib/dcgs.pl index 903c4646..60fe7126 100644 --- a/src/prolog/lib/dcgs.pl +++ b/src/prolog/lib/dcgs.pl @@ -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) :- diff --git a/src/prolog/machine/machine_state_impl.rs b/src/prolog/machine/machine_state_impl.rs index 9c833c91..69e12db6 100644 --- a/src/prolog/machine/machine_state_impl.rs +++ b/src/prolog/machine/machine_state_impl.rs @@ -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 }; },