about summary refs log tree commit diff stats
path: root/038new_text.cc
diff options
context:
space:
mode:
Diffstat (limited to '038new_text.cc')
-rw-r--r--038new_text.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/038new_text.cc b/038new_text.cc
index 0b4e4663..c449e6c9 100644
--- a/038new_text.cc
+++ b/038new_text.cc
@@ -137,3 +137,33 @@ string read_mu_text(int address) {
   }
   return tmp.str();
 }
+
+//:: 'cheating' by using the host system
+
+:(before "End Primitive Recipe Declarations")
+_READ,
+:(before "End Primitive Recipe Numbers")
+put(Recipe_ordinal, "$read", _READ);
+:(before "End Primitive Recipe Checks")
+case _READ: {
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case _READ: {
+  skip_whitespace(cin);
+  string result;
+  if (has_data(cin))
+    cin >> result;
+  products.resize(1);
+  products.at(0).push_back(new_mu_text(result));
+  break;
+}
+
+:(code)
+void skip_whitespace(istream& in) {
+  while (true) {
+    if (!has_data(in)) break;
+    if (isspace(in.peek())) in.get();
+    else break;
+  }
+}