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::In), (XFY, 1000, module_name.clone()));
op_dir
}
}
}
-impl fmt::Display for Constant {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- &Constant::Atom(ref atom) =>
- if atom.as_str().chars().any(|c| ".$'\" ".contains(c)) {
- write!(f, "'{}'", atom.as_str())
- } else {
- write!(f, "{}", atom.as_str())
- },
- &Constant::Char(c) =>
- write!(f, "'{}'", c as u8),
- &Constant::EmptyList =>
- write!(f, "[]"),
- &Constant::Number(ref n) =>
- write!(f, "{}", n),
- &Constant::String(ref s) =>
- write!(f, "\"{}\"", s),
- &Constant::Usize(integer) =>
- write!(f, "u{}", integer)
- }
- }
-}
-
#[derive(PartialEq, Eq, Clone)]
pub enum Term {
AnonVar,
})
}
+ fn print_constant(&mut self, c: Constant) {
+ match c {
+ Constant::Char(c) if c == '\n' =>
+ self.outputter.append("'\\n'"),
+// Constant::Char(c) if c == '\f' =>
+// self.outputter.append("\\f"),
+ Constant::Char(c) if c == '\r' =>
+ self.outputter.append("'\\r'"),
+ Constant::Char(c) if c == '\t' =>
+ self.outputter.append("'\\t'"),
+// Constant::Char(c) if c == '\b' =>
+// self.outputter.append("\\b"),
+// Constant::Char(c) if c == '\\a' =>
+// self.outputter.append("\a"),
+// Constant::Char(c) if c == '\\v' =>
+// self.outputter.append("\\v"),
+ _ =>
+ self.outputter.append(format!("{}", c).as_str())
+ }
+ }
+
fn handle_heap_term(&mut self, iter: &mut HCPreOrderIterator)
{
let heap_val = match self.check_for_seen(iter) {
self.outputter.append("[]");
},
HeapCellValue::Addr(Addr::Con(c)) =>
- self.outputter.append(format!("{}", c).as_str()),
+ self.print_constant(c),
HeapCellValue::Addr(Addr::Lis(_)) => {
let cell = Rc::new(Cell::new(true));
}
}
+impl fmt::Display for Constant {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ &Constant::Atom(ref atom) =>
+ if atom.as_str().chars().any(|c| ".$'\" ".contains(c)) {
+ write!(f, "'{}'", atom.as_str())
+ } else {
+ write!(f, "{}", atom.as_str())
+ },
+ &Constant::Char(c) =>
+ write!(f, "'{}'", c as u8),
+ &Constant::EmptyList =>
+ write!(f, "[]"),
+ &Constant::Number(ref n) =>
+ write!(f, "{}", n),
+ &Constant::String(ref s) =>
+ write!(f, "\"{}\"", s),
+ &Constant::Usize(integer) =>
+ write!(f, "u{}", integer)
+ }
+ }
+}
+
impl fmt::Display for ClauseName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.as_str())
(\==)/2, (@=<)/2, (@>=)/2, (@<)/2, (@>)/2, (=@=)/2, (\=@=)/2,
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.
:- op(700, xfx, is).
:- op(500, yfx, +).
% 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, G4, B) :- compound(G1), G1 = ->(G2, G3), (G2 -> G3 ; '$set_cp'(B), G4).
macro_rules! clause_name {
+ ($name: expr, $tbl: expr) => (
+ ClauseName::User(TabledRc::new($name, $tbl.clone()))
+ ) ;
($name: expr) => (
ClauseName::BuiltIn($name)
)
-Subproject commit d52da58a5d5c3404305466a53c2682ef84274085
+Subproject commit 52034e3a66b694fd16b164c509c525aeaf28470a