about summary refs log tree commit diff stats
path: root/cpp/014types
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-17 21:55:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-17 21:58:47 -0700
commit75845f2230fa998c9fdf71b4711bcbc2794daa4b (patch)
tree7b8c79936195dac26f2169cf7d72400b6258eeaa /cpp/014types
parentb38e581993c4e7ae001572cbdb1855bc8d8db5b3 (diff)
downloadmu-75845f2230fa998c9fdf71b4711bcbc2794daa4b.tar.gz
1091
Diffstat (limited to 'cpp/014types')
-rw-r--r--cpp/014types21
1 files changed, 17 insertions, 4 deletions
diff --git a/cpp/014types b/cpp/014types
index 867cb28d..226be5ee 100644
--- a/cpp/014types
+++ b/cpp/014types
@@ -31,10 +31,8 @@ void insert_container(const string& command, kind_of_type kind, istream& in) {
   t.name = name;
   t.kind = kind;
   while (!in.eof()) {
-    skip_comments_and_newlines(in);
-    skip_whitespace(in);
+    skip_whitespace_and_comments(in);
     string element = next_word(in);
-    skip_comments_and_newlines(in);
     if (element == "]") break;
     istringstream inner(element);
     t.element_names.push_back(slurp_until(inner, ':'));
@@ -81,9 +79,24 @@ for (size_t i = 0; i < recently_added_types.size(); ++i) {
   Type.erase(recently_added_types[i]);
 }
 recently_added_types.clear();
+//: lastly, ensure scenarios are consistent by always starting them at the
+//: same type number.
 Next_type_number = 1000;
 :(before "End One-time Setup")
 assert(Next_type_number < 1000);
 Next_type_number = 1000;
 
-//: lastly, ensure scenarios are consistent by always starting 
+:(code)
+void skip_bracket(istream& in, string message) {
+  skip_whitespace(in);  skip_comments_and_newlines(in);  skip_whitespace(in);
+  if (in.get() != '[')
+    raise << message << '\n';
+}
+
+void skip_whitespace_and_comments(istream& in) {
+  while (true) {
+    if (isspace(in.peek())) in.get();
+    else if (in.peek() == '#') skip_comment(in);
+    else break;
+  }
+}