about summary refs log tree commit diff stats
path: root/056recipe_header.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-09 01:30:02 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-09 01:31:05 -0800
commit4135fcd978395bb688cc7582224d676b4b16ff8f (patch)
tree4e1f95a3ba709ba4b4ce78570bcb3362a18e49f6 /056recipe_header.cc
parent0c0bc3aebb9f20113fc6b15180f94ed0073e96cc (diff)
downloadmu-4135fcd978395bb688cc7582224d676b4b16ff8f.tar.gz
2407 - bugfix: parsing recipe headers
Diffstat (limited to '056recipe_header.cc')
-rw-r--r--056recipe_header.cc28
1 files changed, 26 insertions, 2 deletions
diff --git a/056recipe_header.cc b/056recipe_header.cc
index 66e5217b..e6a83383 100644
--- a/056recipe_header.cc
+++ b/056recipe_header.cc
@@ -37,17 +37,41 @@ void load_recipe_header(istream& in, recipe& result) {
     if (s == "->") break;
     result.ingredients.push_back(reagent(s));
     trace(9999, "parse") << "header ingredient: " << result.ingredients.back().original_string << end();
-    skip_whitespace(in);
+    skip_whitespace_and_comments(in);
   }
   while (in.peek() != '[') {
     string s = next_word(in);
     result.products.push_back(reagent(s));
     trace(9999, "parse") << "header product: " << result.products.back().original_string << end();
-    skip_whitespace(in);
+    skip_whitespace_and_comments(in);
   }
   // End Load Recipe Header(result)
 }
 
+:(scenario recipe_handles_stray_comma)
+recipe main [
+  1:number/raw <- add2 3, 5
+]
+recipe add2 x:number, y:number -> z:number, [
+  local-scope
+  load-ingredients
+  z:number <- add x, y
+  reply z
+]
++mem: storing 8 in location 1
+
+:(scenario recipe_handles_stray_comma_2)
+recipe main [
+  foo
+]
+recipe foo, [
+  1:number/raw <- add 2, 2
+]
+recipe bar [
+  1:number/raw <- add 2, 3
+]
++mem: storing 4 in location 1
+
 //: If a recipe never mentions any ingredients or products, assume it has a header.
 
 :(scenario recipe_without_ingredients_or_products_has_header)