]> Repositorios git - scryer-prolog.git/commitdiff
re: #75, #52
authorMark Thom <[email protected]>
Mon, 1 Apr 2019 04:30:42 +0000 (22:30 -0600)
committerMark Thom <[email protected]>
Mon, 1 Apr 2019 04:30:42 +0000 (22:30 -0600)
Cargo.toml
src/prolog/codegen.rs
src/prolog/heap_print.rs
src/prolog/lib/builtins.pl
src/prolog/lib/dcgs.pl
src/prolog/machine/machine_state_impl.rs

index fc4b56d503eda4228b07e73f8d6d8a608d3be19a..d1610c55bd99daf39ccb6538486c745f8e4f3826 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "scryer-prolog"
-version = "0.8.33"
+version = "0.8.34"
 authors = ["Mark Thom <[email protected]>"]
 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"
 
index 462cda0fce1ac702d15443f74e100439e3d7168f..f05e8d58b7846da868506718faba24c08d7120da 100644 (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) => {
index 38429884a8102116af4d3fc57f5e0cb9bb4c3e1e..c7ef60edbd252f615c81f67eb064beac72b64aba 100644 (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('\'');
index fb3933b8fe37d68a5201702bc835f48b3a8273b2..3639baf7e2dd2d29981698e4067f9d741a96026d 100644 (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, [>, <, =\=, =:=, >=, =<]).
index 903c4646082436760f372f2c28e0a66548a36a43..60fe71264f4dbe5089b1af094064f788f5bc108f 100644 (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) :-
index 9c833c91819688e9ffbbf5ab1476420346455f91..69e12db607346064c261aea12b4c3c71bdc02f3c 100644 (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
                 };
             },