about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-10-04 09:33:17 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-10-04 09:33:17 -0700
commitd731455459178fc954c4bb2e48a78ba0c4cfbc89 (patch)
tree9a31fa23ca2aee1ceb29e136f9c4ee524210a566
parentc594062cba29a09abf9574f72f3d2a6e9a2aa224 (diff)
downloadmu-d731455459178fc954c4bb2e48a78ba0c4cfbc89.tar.gz
3439
-rw-r--r--011load.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/011load.cc b/011load.cc
index ab0d44bf..cc329b5c 100644
--- a/011load.cc
+++ b/011load.cc
@@ -155,7 +155,15 @@ string next_word(istream& in) {
   ostringstream out;
   slurp_word(in, out);
   skip_whitespace_and_comments_but_not_newline(in);
-  return out.str();
+  string result = out.str();
+  if (result != "[" && ends_with(result, '['))
+    raise << "insert a space before '[' in '" << result << "'\n" << end();
+  return result;
+}
+
+bool ends_with(const string& s, const char c) {
+  if (s.empty()) return false;
+  return *s.rbegin() == c;
 }
 
 :(before "End Globals")
@@ -356,6 +364,13 @@ void test_parse_comment_terminated_by_eof() {
   cerr << ".";  // termination = success
 }
 
+:(scenario warn_on_missing_space_before_bracket)
+% Hide_errors = true;
+def main[
+  1:number <- copy 23
+]
++error: insert a space before '[' in 'main['
+
 :(scenario forbid_redefining_recipes)
 % Hide_errors = true;
 def main [