about summary refs log tree commit diff stats
path: root/011load.cc
diff options
context:
space:
mode:
Diffstat (limited to '011load.cc')
-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 [