PrinterOutputter { contents: String::new() }
}
- fn append(&mut self, contents: &str) {
+ fn append(&mut self, contents: &str) {
if requires_space(&self.contents, contents) {
self.push_char(' ');
}
-
+
self.contents += contents;
}
match atom.chars().last() {
Some(ac) => op.chars().next().map(|oc| {
if ac == '0' {
- oc == 'b' || oc == 'x' || oc == 'o' || !non_quoted_token(op.chars())
+ oc == 'b' || oc == 'x' || oc == 'o' || oc == '\''
} else if alpha_numeric_char!(ac) {
oc == '(' || alpha_numeric_char!(oc)
} else if graphic_token_char!(ac) {
#[inline]
fn append_str(&mut self, s: &str) {
self.last_item_idx = self.outputter.len();
- self.outputter.append(s);
+ self.outputter.append(s);
}
fn offset_as_string(&self, addr: Addr) -> Option<String> {
}
} else if !self.at_cdr("") {
self.append_str("[]");
- },
+ },
DoubleQuotes::Atom => {
let borrowed_str = s.borrow();
}
}
}
-
+
fn push_list(&mut self) {
let cell = Rc::new(Cell::new(true));
if !(self.machine_st.b > 0) {
if bindings.is_empty() {
+ let space = if requires_space(&attr_goals, ".") { " " } else { "" };
+
if !attr_goals.is_empty() {
- println!("{}.", attr_goals);
+ println!("{}{}.", attr_goals, space);
} else {
println!("true.");
}
if !attr_goals.is_empty() {
if bindings.is_empty() {
- let space = if requires_space(&attr_goals, ".") { " " } else { "" };
- write!(raw_stdout, "{}{}", attr_goals, space).unwrap();
+ write!(raw_stdout, "{}", attr_goals).unwrap();
} else {
- let space = if requires_space(&attr_goals, ".") { " " } else { "" };
- write!(raw_stdout, "{}, {}{}", bindings, attr_goals, space).unwrap();
+ write!(raw_stdout, "{}, {}", bindings, attr_goals).unwrap();
}
} else if !bindings.is_empty() {
- let space = if requires_space(&bindings, ".") { " " } else { "" };
- write!(raw_stdout, "{}{}", bindings, space).unwrap();
+ write!(raw_stdout, "{}", bindings).unwrap();
}
if self.machine_st.b > 0 {
raw_stdout.flush().unwrap();
- let result = match next_keypress(raw_stdout) {
- ContinueResult::ContinueQuery =>
- self.continue_query(&alloc_locs, &mut heap_locs),
+ let result = match next_keypress() {
+ ContinueResult::ContinueQuery => {
+ write!(raw_stdout, " ;\r\n").unwrap();
+ self.continue_query(&alloc_locs, &mut heap_locs)
+ },
ContinueResult::Conclude => {
+ write!(raw_stdout, " ...\r\n").unwrap();
self.machine_st.absorb_snapshot(snapshot);
return;
}
if bindings.is_empty() && attr_goals.is_empty() {
write!(raw_stdout, "true.\r\n").unwrap();
} else {
- write!(raw_stdout, ".\r\n").unwrap();
+ let space = if !attr_goals.is_empty() {
+ if requires_space(&attr_goals, ".") { " " } else { "" }
+ } else {
+ if requires_space(&bindings, ".") { " " } else { "" }
+ };
+
+ write!(raw_stdout, "{}.\r\n", space).unwrap();
}
break;
use termion::input::TermRead;
use termion::event::Key;
-use termion::raw::{RawTerminal};
-use std::io::{Write, stdin};
+use std::io::stdin;
use std::fmt;
impl fmt::Display for LocalCodePtr {
}
pub
-fn next_keypress(mut stdout: RawTerminal<std::io::Stdout>) -> ContinueResult
+fn next_keypress() -> ContinueResult
{
let stdin = stdin();
for c in stdin.keys() {
match c.unwrap() {
- Key::Char(' ') | Key::Char(';') => {
- write!(stdout, " ;\r\n").unwrap();
- return ContinueResult::ContinueQuery;
- },
- Key::Char('.') => {
- write!(stdout, " .\r\n").unwrap();
- return ContinueResult::Conclude;
- },
+ Key::Char(' ') | Key::Char(';') =>
+ return ContinueResult::ContinueQuery,
+ Key::Char('.') =>
+ return ContinueResult::Conclude,
_ => {}
}
}