diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-06 10:20:54 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-06 10:20:54 -0700 |
commit | fe263c523acdc48c3232afbdf8c2adb41cd4f337 (patch) | |
tree | 7ccf8b5a32ceb7f494071812033e418d216a6537 | |
parent | e26495c53d043d60d6cadf2b638818d53f3c9a74 (diff) | |
download | mu-fe263c523acdc48c3232afbdf8c2adb41cd4f337.tar.gz |
1021 - extensible top-level command handler loop
-rw-r--r-- | cpp/011load | 16 |
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()) |