print chars somewhat appropriately.
This commit is contained in:
@@ -167,7 +167,6 @@ pub fn default_op_dir() -> OpDir {
|
|||||||
op_dir.insert((clause_name!(":-"), Fixity::In), (XFX, 1200, module_name.clone()));
|
op_dir.insert((clause_name!(":-"), Fixity::In), (XFX, 1200, module_name.clone()));
|
||||||
op_dir.insert((clause_name!(":-"), Fixity::Pre), (FX, 1200, module_name.clone()));
|
op_dir.insert((clause_name!(":-"), Fixity::Pre), (FX, 1200, module_name.clone()));
|
||||||
op_dir.insert((clause_name!("?-"), Fixity::Pre), (FX, 1200, module_name.clone()));
|
op_dir.insert((clause_name!("?-"), Fixity::Pre), (FX, 1200, module_name.clone()));
|
||||||
op_dir.insert((clause_name!(","), Fixity::In), (XFY, 1000, module_name.clone()));
|
|
||||||
|
|
||||||
op_dir
|
op_dir
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ pub trait HCValueOutputter {
|
|||||||
type Output;
|
type Output;
|
||||||
|
|
||||||
fn new() -> Self;
|
fn new() -> Self;
|
||||||
|
fn push_char(&mut self, char);
|
||||||
fn append(&mut self, &str);
|
fn append(&mut self, &str);
|
||||||
fn begin_new_var(&mut self);
|
fn begin_new_var(&mut self);
|
||||||
fn result(self) -> Self::Output;
|
fn result(self) -> Self::Output;
|
||||||
@@ -69,6 +70,10 @@ impl HCValueOutputter for PrinterOutputter {
|
|||||||
self.contents += contents;
|
self.contents += contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn push_char(&mut self, c: char) {
|
||||||
|
self.contents.push(c);
|
||||||
|
}
|
||||||
|
|
||||||
fn begin_new_var(&mut self) {
|
fn begin_new_var(&mut self) {
|
||||||
if self.contents.len() != 0 {
|
if self.contents.len() != 0 {
|
||||||
self.contents += ", ";
|
self.contents += ", ";
|
||||||
@@ -239,6 +244,11 @@ impl<'a, Formatter: HCValueFormatter, Outputter: HCValueOutputter>
|
|||||||
self.outputter.append("'\\r'"),
|
self.outputter.append("'\\r'"),
|
||||||
Constant::Char(c) if c == '\t' =>
|
Constant::Char(c) if c == '\t' =>
|
||||||
self.outputter.append("'\\t'"),
|
self.outputter.append("'\\t'"),
|
||||||
|
Constant::Char(c) => {
|
||||||
|
self.outputter.append("'");
|
||||||
|
self.outputter.push_char(c);
|
||||||
|
self.outputter.append("'");
|
||||||
|
},
|
||||||
// Constant::Char(c) if c == '\b' =>
|
// Constant::Char(c) if c == '\b' =>
|
||||||
// self.outputter.append("\\b"),
|
// self.outputter.append("\\b"),
|
||||||
// Constant::Char(c) if c == '\\a' =>
|
// Constant::Char(c) if c == '\\a' =>
|
||||||
|
|||||||
@@ -7,15 +7,6 @@
|
|||||||
(\==)/2, (@=<)/2, (@>=)/2, (@<)/2, (@>)/2, (=@=)/2, (\=@=)/2,
|
(\==)/2, (@=<)/2, (@>=)/2, (@<)/2, (@>)/2, (=@=)/2, (\=@=)/2,
|
||||||
catch/3, throw/1, true/0, false/0]).
|
catch/3, throw/1, true/0, false/0]).
|
||||||
|
|
||||||
','(G1, G2) :- '$get_cp'(B), ','(G1, G2, B).
|
|
||||||
|
|
||||||
','(!, ','(G1, G2), B) :- '$set_cp'(B), ','(G1, G2, B).
|
|
||||||
','(!, !, B) :- '$set_cp'(B).
|
|
||||||
','(!, G, B) :- '$set_cp'(B), G.
|
|
||||||
','(G, ','(G2, G3), B) :- !, G, ','(G2, G3, B).
|
|
||||||
','(G, !, B) :- !, G, '$set_cp'(B).
|
|
||||||
','(G1, G2, _) :- G1, G2.
|
|
||||||
|
|
||||||
% arithmetic operators.
|
% arithmetic operators.
|
||||||
:- op(700, xfx, is).
|
:- op(700, xfx, is).
|
||||||
:- op(500, yfx, +).
|
:- op(500, yfx, +).
|
||||||
@@ -72,6 +63,15 @@ false :- '$fail'.
|
|||||||
|
|
||||||
% control operators.
|
% control operators.
|
||||||
|
|
||||||
|
','(G1, G2) :- '$get_cp'(B), ','(G1, G2, B).
|
||||||
|
|
||||||
|
','(!, ','(G1, G2), B) :- '$set_cp'(B), ','(G1, G2, B).
|
||||||
|
','(!, !, B) :- '$set_cp'(B).
|
||||||
|
','(!, G, B) :- '$set_cp'(B), G.
|
||||||
|
','(G, ','(G2, G3), B) :- !, G, ','(G2, G3, B).
|
||||||
|
','(G, !, B) :- !, G, '$set_cp'(B).
|
||||||
|
','(G1, G2, _) :- G1, G2.
|
||||||
|
|
||||||
;(G1, G2) :- '$get_cp'(B), ;(G1, G2, B).
|
;(G1, G2) :- '$get_cp'(B), ;(G1, G2, B).
|
||||||
|
|
||||||
;(G1, G4, B) :- compound(G1), G1 = ->(G2, G3), (G2 -> G3 ; '$set_cp'(B), G4).
|
;(G1, G4, B) :- compound(G1), G1 = ->(G2, G3), (G2 -> G3 ; '$set_cp'(B), G4).
|
||||||
@@ -87,8 +87,8 @@ G1 -> G2 :- '$get_cp'(B), ->(G1, G2, B).
|
|||||||
|
|
||||||
% arg.
|
% arg.
|
||||||
|
|
||||||
/* Here is the old, SWI Prolog-imitative arg/3. The new, ISO Prolog
|
/* Here is the old, SWI Prolog-imitative arg/3. It has been superseded by an ISO Prolog
|
||||||
* compliant arg/3 is implemented in Rust.
|
* compliant arg/3 implemented in Rust.
|
||||||
|
|
||||||
arg(N, Functor, Arg) :- var(N), !, functor(Functor, _, Arity), arg_(N, 1, Arity, Functor, Arg).
|
arg(N, Functor, Arg) :- var(N), !, functor(Functor, _, Arity), arg_(N, 1, Arity, Functor, Arg).
|
||||||
arg(N, Functor, Arg) :- integer(N), !, functor(Functor, _, Arity), '$get_arg'(N, Functor, Arg).
|
arg(N, Functor, Arg) :- integer(N), !, functor(Functor, _, Arity), '$get_arg'(N, Functor, Arg).
|
||||||
|
|||||||
Submodule src/prolog/parser updated: 52034e3a66...25b4224779
@@ -36,6 +36,10 @@ impl HCValueOutputter for TestOutputter {
|
|||||||
self.focus += focus;
|
self.focus += focus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn push_char(&mut self, c: char) {
|
||||||
|
self.focus.push(c);
|
||||||
|
}
|
||||||
|
|
||||||
fn begin_new_var(&mut self) {
|
fn begin_new_var(&mut self) {
|
||||||
if !self.focus.is_empty() {
|
if !self.focus.is_empty() {
|
||||||
let mut focus = String::new();
|
let mut focus = String::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user