]> Repositorios git - scryer-prolog.git/commitdiff
print certain atoms in single quotes.
authorMark Thom <[email protected]>
Thu, 17 May 2018 02:34:53 +0000 (20:34 -0600)
committerMark Thom <[email protected]>
Thu, 17 May 2018 02:34:53 +0000 (20:34 -0600)
src/prolog/ast.rs

index c5f24cb4b7e93afb607006688f504fbf03b92e4f..721ec05d706a37201896dc22eb2aa1ee27cbdeba 100644 (file)
@@ -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 =>