From ddb79e6b3415d9243a1b37eb7356c563fc6e9532 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Wed, 16 May 2018 20:34:53 -0600 Subject: [PATCH] print certain atoms in single quotes. --- src/prolog/ast.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/prolog/ast.rs b/src/prolog/ast.rs index c5f24cb4..721ec05d 100644 --- a/src/prolog/ast.rs +++ b/src/prolog/ast.rs @@ -552,7 +552,11 @@ impl fmt::Display for Constant { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { &Constant::Atom(ref atom) => - write!(f, "{}", 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 => -- 2.54.0