From dcc060c7d4ef56b978beb34ddce8d8ffcec94fa6 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 25 Feb 2016 17:17:20 -0800 Subject: 2706 - update html --- html/011load.cc.html | 126 ++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 66 deletions(-) (limited to 'html/011load.cc.html') diff --git a/html/011load.cc.html b/html/011load.cc.html index 205faacf..180cda8d 100644 --- a/html/011load.cc.html +++ b/html/011load.cc.html @@ -40,8 +40,8 @@ recipe main [ 1:number <- copy 23 ] +parse: instruction: copy -+parse: ingredient: {"23": "literal"} -+parse: product: {"1": "number"} ++parse: ingredient: 23: "literal" ++parse: product: 1: "number" :(code) vector<recipe_ordinal> load(string form) { @@ -62,9 +62,9 @@ vector<recipe_ordinal> load(istream& in result.push_back(slurp_recipe(in)); } else if (command == "recipe!") { - Disable_redefine_warnings = true; + Disable_redefine_checks = true; result.push_back(slurp_recipe(in)); - Disable_redefine_warnings = false; + Disable_redefine_checks = false; } // End Command Handlers else { @@ -77,22 +77,22 @@ vector<recipe_ordinal> load(istream& in long long int slurp_recipe(istream& in) { recipe result; result.name = next_word(in); + // End Load Recipe Name skip_whitespace_but_not_newline(in); - // End recipe Refinements + // End Recipe Refinements if (result.name.empty()) raise_error << "empty result.name\n" << end(); trace(9991, "parse") << "--- defining " << result.name << end(); - if (!contains_key(Recipe_ordinal, result.name)) { + if (!contains_key(Recipe_ordinal, result.name)) put(Recipe_ordinal, result.name, Next_recipe_ordinal++); - } if (Recipe.find(get(Recipe_ordinal, result.name)) != Recipe.end()) { trace(9991, "parse") << "already exists" << end(); - if (warn_on_redefine(result.name)) - raise << "redefining recipe " << result.name << "\n" << end(); + if (should_check_for_redefine(result.name)) + raise_error << "redefining recipe " << result.name << "\n" << end(); Recipe.erase(get(Recipe_ordinal, result.name)); } slurp_body(in, result); - // End recipe Body(result) + // End Recipe Body(result) put(Recipe, get(Recipe_ordinal, result.name), result); // track added recipes because we may need to undo them in tests; see below Recently_added_recipes.push_back(get(Recipe_ordinal, result.name)); @@ -108,9 +108,9 @@ void slurp_body(istream& in; while (next_instruction(in, &curr)) { // End Rewrite Instruction(curr, recipe result) - trace(9992, "load") << "after rewriting: " << curr.to_string() << end(); - if (!curr.is_clear()) { - curr.original_string = curr.to_string(); + trace(9992, "load") << "after rewriting: " << to_string(curr) << end(); + if (!curr.is_empty()) { + curr.original_string = to_string(curr); result.steps.push_back(curr); } } @@ -136,9 +136,8 @@ bool next_instruction(istream& in(in); } skip_whitespace_and_comments(in); - if (SIZE(words) == 1 && words.at(0) == "]") { + if (SIZE(words) == 1 && words.at(0) == "]") return false; // end of recipe - } if (SIZE(words) == 1 && !isalnum(words.at(0).at(0)) && words.at(0).at(0) != '$') { curr->is_label = true; @@ -153,9 +152,8 @@ bool next_instruction(istream& in.begin(); if (find(words.begin(), words.end(), "<-") != words.end()) { - for (; *p != "<-"; ++p) { + for (; *p != "<-"; ++p) curr->products.push_back(reagent(*p)); - } ++p; // skip <- } @@ -166,18 +164,15 @@ bool next_instruction(istream& in->old_name = curr->name = *p; p++; // curr->operation will be set in a later layer - for (; p != words.end(); ++p) { + for (; p != words.end(); ++p) curr->ingredients.push_back(reagent(*p)); - } trace(9993, "parse") << "instruction: " << curr->name << end(); trace(9993, "parse") << " number of ingredients: " << SIZE(curr->ingredients) << end(); - for (vector<reagent>::iterator p = curr->ingredients.begin(); p != curr->ingredients.end(); ++p) { - trace(9993, "parse") << " ingredient: " << p->to_string() << end(); - } - for (vector<reagent>::iterator p = curr->products.begin(); p != curr->products.end(); ++p) { - trace(9993, "parse") << " product: " << p->to_string() << end(); - } + for (vector<reagent>::iterator p = curr->ingredients.begin(); p != curr->ingredients.end(); ++p) + trace(9993, "parse") << " ingredient: " << to_string(*p) << end(); + for (vector<reagent>::iterator p = curr->products.begin(); p != curr->products.end(); ++p) + trace(9993, "parse") << " product: " << to_string(*p) << end(); if (!has_data(in)) { raise_error << "9: unbalanced '[' for recipe\n" << end(); return false; @@ -245,14 +240,14 @@ void skip_comment(istream& in//: Warn if a recipe gets redefined, because large codebases can accidentally //: step on their own toes. But there'll be many occasions later where -//: we'll want to disable the warnings. +//: we'll want to disable the errors. :(before "End Globals") -bool Disable_redefine_warnings = false; +bool Disable_redefine_checks = false; :(before "End Setup") -Disable_redefine_warnings = false; +Disable_redefine_checks = false; :(code) -bool warn_on_redefine(const string& recipe_name) { - if (Disable_redefine_warnings) return false; +bool should_check_for_redefine(const string& recipe_name) { + if (Disable_redefine_checks) return false; return true; } @@ -261,9 +256,8 @@ bool warn_on_redefine(const string& recipe_na void show_rest_of_stream(istream& in) { cerr << '^'; char c; - while (in >> c) { + while (in >> c) cerr << c; - } cerr << "$\n"; exit(0); } @@ -294,8 +288,8 @@ recipe main [ 1:number <- copy 23 ] +parse: instruction: copy -+parse: ingredient: {"23": "literal"} -+parse: product: {"1": "number"} ++parse: ingredient: 23: "literal" ++parse: product: 1: "number" :(scenario parse_comment_amongst_instruction) recipe main [ @@ -303,8 +297,8 @@ recipe main [ 1:number <- copy 23 ] +parse: instruction: copy -+parse: ingredient: {"23": "literal"} -+parse: product: {"1": "number"} ++parse: ingredient: 23: "literal" ++parse: product: 1: "number" :(scenario parse_comment_amongst_instruction_2) recipe main [ @@ -313,8 +307,8 @@ recipe main [ # comment ] +parse: instruction: copy -+parse: ingredient: {"23": "literal"} -+parse: product: {"1": "number"} ++parse: ingredient: 23: "literal" ++parse: product: 1: "number" :(scenario parse_comment_amongst_instruction_3) recipe main [ @@ -323,19 +317,19 @@ recipe main [ 2:number <- copy 23 ] +parse: instruction: copy -+parse: ingredient: {"23": "literal"} -+parse: product: {"1": "number"} ++parse: ingredient: 23: "literal" ++parse: product: 1: "number" +parse: instruction: copy -+parse: ingredient: {"23": "literal"} -+parse: product: {"2": "number"} ++parse: ingredient: 23: "literal" ++parse: product: 2: "number" :(scenario parse_comment_after_instruction) recipe main [ 1:number <- copy 23 # comment ] +parse: instruction: copy -+parse: ingredient: {"23": "literal"} -+parse: product: {"1": "number"} ++parse: ingredient: 23: "literal" ++parse: product: 1: "number" :(scenario parse_label) recipe main [ @@ -354,43 +348,43 @@ recipe main [ 1:number <- copy 23/foo:bar:baz ] +parse: instruction: copy -+parse: ingredient: {"23": "literal", "foo": <"bar" : <"baz" : <>>>} -+parse: product: {"1": "number"} ++parse: ingredient: 23: "literal", {"foo": ("bar" "baz")} ++parse: product: 1: "number" :(scenario parse_multiple_products) recipe main [ 1:number, 2:number <- copy 23 ] +parse: instruction: copy -+parse: ingredient: {"23": "literal"} -+parse: product: {"1": "number"} -+parse: product: {"2": "number"} ++parse: ingredient: 23: "literal" ++parse: product: 1: "number" ++parse: product: 2: "number" :(scenario parse_multiple_ingredients) recipe main [ 1:number, 2:number <- copy 23, 4:number ] +parse: instruction: copy -+parse: ingredient: {"23": "literal"} -+parse: ingredient: {"4": "number"} -+parse: product: {"1": "number"} -+parse: product: {"2": "number"} ++parse: ingredient: 23: "literal" ++parse: ingredient: 4: "number" ++parse: product: 1: "number" ++parse: product: 2: "number" :(scenario parse_multiple_types) recipe main [ 1:number, 2:address:number <- copy 23, 4:number ] +parse: instruction: copy -+parse: ingredient: {"23": "literal"} -+parse: ingredient: {"4": "number"} -+parse: product: {"1": "number"} -+parse: product: {"2": <"address" : <"number" : <>>>} ++parse: ingredient: 23: "literal" ++parse: ingredient: 4: "number" ++parse: product: 1: "number" ++parse: product: 2: ("address" "number") :(scenario parse_properties) recipe main [ - 1:number:address/lookup <- copy 23 + 1:address:number/lookup <- copy 23 ] -+parse: product: {"1": <"number" : <"address" : <>>>, "lookup": <>} ++parse: product: 1: ("address" "number"), {"lookup": ()} //: this test we can't represent with a scenario :(code) @@ -403,26 +397,26 @@ void test_parse_comment_terminated_by_eof() "."; // termination = success } -:(scenario warn_on_redefine) -% Hide_warnings = true; +:(scenario forbid_redefining_recipes) +% Hide_errors = true; recipe main [ 1:number <- copy 23 ] recipe main [ 1:number <- copy 24 ] -+warn: redefining recipe main ++error: redefining recipe main -:(scenario redefine_without_warning) -% Hide_warnings = true; +:(scenario permit_forcibly_redefining_recipes) +% Hide_errors = true; recipe main [ 1:number <- copy 23 ] recipe! main [ 1:number <- copy 24 ] --warn: redefining recipe main -$warn: 0 +-error: redefining recipe main +$error: 0 -- cgit 1.4.1-2-gfad0