about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-16 18:10:38 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-16 18:10:38 -0700
commit3a24d35f7582591e274d0de6fd002b7491c82696 (patch)
treefcf9e0037261f2a730a388db7dc27c5d6ebb7fdd /cpp
parent69f04c3fb0136778b80f7f64e16ae37cf8d22907 (diff)
downloadmu-3a24d35f7582591e274d0de6fd002b7491c82696.tar.gz
930
Diffstat (limited to 'cpp')
-rw-r--r--cpp/011load11
-rw-r--r--cpp/012run3
2 files changed, 8 insertions, 6 deletions
diff --git a/cpp/011load b/cpp/011load
index ac41ab44..707f9e59 100644
--- a/cpp/011load
+++ b/cpp/011load
@@ -9,14 +9,15 @@ recipe main [
 +parse:   product: {name: "1", type: 1}
 
 :(code)
-int add_recipes(string form) {
+vector<recipe_number> add_recipes(string form) {
   istringstream in(form);
-  int result = add_recipe(in);
-  while (!in.eof()) add_recipe(in);
+  vector<recipe_number> result;
+  while (!in.eof())
+    result.push_back(add_recipe(in));
   return result;
 }
 
-int add_recipe(istream& in) {
+recipe_number add_recipe(istream& in) {
   in >> std::noskipws;
   skip_comments_and_newlines(in);
   string _recipe = next_word(in);
@@ -31,7 +32,7 @@ int add_recipe(istream& in) {
 //?     raise << "empty recipe name in " << in.str() << '\n';
   if (Recipe_number.find(recipe_name) == Recipe_number.end())
     Recipe_number[recipe_name] = Next_recipe_number++;
-  int r = Recipe_number[recipe_name];
+  recipe_number r = Recipe_number[recipe_name];
 //?   cout << recipe_name << ": adding recipe " << r << '\n'; //? 3
 
   if (next_word(in) != "[")
diff --git a/cpp/012run b/cpp/012run
index 558a264d..42b5d477 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -28,7 +28,8 @@ struct routine {
 
 :(code)
 void run(string form) {
-  run(add_recipes(form));
+  vector<recipe_number> recipes_added = add_recipes(form);
+  run(recipes_added.front());
 }
 
 void run(recipe_number r) {