about summary refs log tree commit diff stats
path: root/cpp/011load
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-06 10:20:54 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-06 10:20:54 -0700
commitfe263c523acdc48c3232afbdf8c2adb41cd4f337 (patch)
tree7ccf8b5a32ceb7f494071812033e418d216a6537 /cpp/011load
parente26495c53d043d60d6cadf2b638818d53f3c9a74 (diff)
downloadmu-fe263c523acdc48c3232afbdf8c2adb41cd4f337.tar.gz
1021 - extensible top-level command handler loop
Diffstat (limited to 'cpp/011load')
-rw-r--r--cpp/011load16
1 files changed, 9 insertions, 7 deletions
diff --git a/cpp/011load b/cpp/011load
index 6479b667..cffcc551 100644
--- a/cpp/011load
+++ b/cpp/011load
@@ -13,18 +13,20 @@ vector<recipe_number> add_recipes(string form) {
   istringstream in(form);
   in >> std::noskipws;
   vector<recipe_number> result;
-  while (!in.eof())
-    result.push_back(add_recipe(in));
+  while (!in.eof()) {
+    skip_comments_and_newlines(in);
+    if (in.eof()) break;
+    string command = next_word(in);
+    // Command Handlers
+    if (command == "recipe")
+      result.push_back(add_recipe(in));
+    // End Command Handlers
+  }
   return result;
 }
 
 recipe_number add_recipe(istream& in) {
   skip_comments_and_newlines(in);
-  string _recipe = next_word(in);
-//?   cout << _recipe; //? 1
-  if (_recipe != "recipe")
-    raise << "top-level forms must be of the form 'recipe _name_ [ _instruction_ ... ]'\n";
-
   string recipe_name = next_word(in);
 //?   cout << "recipe name: ^" << recipe_name << "$\n"; //? 1
   if (recipe_name.empty())