From e4ac3c9e6e5464a0fc0f8fd3763a572e0e180c04 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 1 Dec 2018 14:13:33 -0800 Subject: 4814 --- html/011load.cc.html | 91 +++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 44 deletions(-) (limited to 'html/011load.cc.html') diff --git a/html/011load.cc.html b/html/011load.cc.html index 9319045a..1f42e841 100644 --- a/html/011load.cc.html +++ b/html/011load.cc.html @@ -11,21 +11,23 @@ @@ -60,6 +62,7 @@ if ('onhashchange' in window) { +https://github.com/akkartik/mu/blob/master/011load.cc
   1 //: Phase 1 of running Mu code: load it from a textual representation.
   2 //:
@@ -99,10 +102,10 @@ if ('onhashchange' in window) {
  36       if (r > 0) result.push_back(r);
  37     }
  38     else if (command == "recipe!" || command == "def!") {
- 39       Disable_redefine_checks = true;
+ 39       Disable_redefine_checks = true;
  40       recipe_ordinal r = slurp_recipe(in);
  41       if (r > 0) result.push_back(r);
- 42       Disable_redefine_checks = false;
+ 42       Disable_redefine_checks = false;
  43     }
  44     // End Command Handlers
  45     else {
@@ -118,36 +121,36 @@ if ('onhashchange' in window) {
  55   result.name = next_word(in);
  56   if (result.name.empty()) {
  57     assert(!has_data(in));
- 58     raise << "file ended with 'recipe'\n" << end();
+ 58     raise << "file ended with 'recipe'\n" << end();
  59     return -1;
  60   }
  61   // End Load Recipe Name
  62   skip_whitespace_but_not_newline(in);
  63   // End Recipe Refinements
  64   if (result.name.empty())
- 65     raise << "empty result.name\n" << end();
+ 65     raise << "empty result.name\n" << end();
  66   trace(9991, "parse") << "--- defining " << result.name << end();
- 67   if (!contains_key(Recipe_ordinal, result.name))
- 68     put(Recipe_ordinal, result.name, Next_recipe_ordinal);
- 69   result.ordinal = get(Recipe_ordinal, result.name);
- 70   ++Next_recipe_ordinal;
- 71   if (Recipe.find(get(Recipe_ordinal, result.name)) != Recipe.end()) {
+ 67   if (!contains_key(Recipe_ordinal, result.name))
+ 68     put(Recipe_ordinal, result.name, Next_recipe_ordinal);
+ 69   result.ordinal = get(Recipe_ordinal, result.name);
+ 70   ++Next_recipe_ordinal;
+ 71   if (Recipe.find(get(Recipe_ordinal, result.name)) != Recipe.end()) {
  72     trace(9991, "parse") << "already exists" << end();
  73     if (should_check_for_redefine(result.name))
- 74       raise << "redefining recipe " << result.name << "\n" << end();
- 75     Recipe.erase(get(Recipe_ordinal, result.name));
+ 74       raise << "redefining recipe " << result.name << "\n" << end();
+ 75     Recipe.erase(get(Recipe_ordinal, result.name));
  76   }
  77   slurp_body(in, result);
  78   // End Recipe Body(result)
- 79   put(Recipe, get(Recipe_ordinal, result.name), result);
- 80   return get(Recipe_ordinal, result.name);
+ 79   put(Recipe, get(Recipe_ordinal, result.name), result);
+ 80   return get(Recipe_ordinal, result.name);
  81 }
  82 
  83 void slurp_body(istream& in, recipe& result) {
  84   in >> std::noskipws;
  85   skip_whitespace_but_not_newline(in);
  86   if (in.get() != '[')
- 87     raise << result.name << ": recipe body must begin with '['\n" << end();
+ 87     raise << result.name << ": recipe body must begin with '['\n" << end();
  88   skip_whitespace_and_comments(in);  // permit trailing comment after '['
  89   instruction curr;
  90   while (next_instruction(in, &curr)) {
@@ -162,7 +165,7 @@ if ('onhashchange' in window) {
  99   curr->clear();
 100   skip_whitespace_and_comments(in);
 101   if (!has_data(in)) {
-102     raise << "incomplete recipe at end of file (0)\n" << end();
+102     raise << "incomplete recipe at end of file (0)\n" << end();
 103     return false;
 104   }
 105 
@@ -170,13 +173,13 @@ if ('onhashchange' in window) {
 107   while (has_data(in) && in.peek() != '\n') {
 108     skip_whitespace_but_not_newline(in);
 109     if (!has_data(in)) {
-110       raise << "incomplete recipe at end of file (1)\n" << end();
+110       raise << "incomplete recipe at end of file (1)\n" << end();
 111       return false;
 112     }
 113     string word = next_word(in);
 114     if (word.empty()) {
 115       assert(!has_data(in));
-116       raise << "incomplete recipe at end of file (2)\n" << end();
+116       raise << "incomplete recipe at end of file (2)\n" << end();
 117       return false;
 118     }
 119     words.push_back(word);
@@ -191,7 +194,7 @@ if ('onhashchange' in window) {
 128     curr->label = words.at(0);
 129     trace(9993, "parse") << "label: " << curr->label << end();
 130     if (!has_data(in)) {
-131       raise << "incomplete recipe at end of file (3)\n" << end();
+131       raise << "incomplete recipe at end of file (3)\n" << end();
 132       return false;
 133     }
 134     return true;
@@ -205,7 +208,7 @@ if ('onhashchange' in window) {
 142   }
 143 
 144   if (p == words.end()) {
-145     raise << "instruction prematurely ended with '<-'\n" << end();
+145     raise << "instruction prematurely ended with '<-'\n" << end();
 146     return false;
 147   }
 148   curr->name = *p;  ++p;
@@ -221,7 +224,7 @@ if ('onhashchange' in window) {
 158   for (vector<reagent>::iterator p = curr->products.begin();  p != curr->products.end();  ++p)
 159     trace(9993, "parse") << "  product: " << to_string(*p) << end();
 160   if (!has_data(in)) {
-161     raise << "9: unbalanced '[' for recipe\n" << end();
+161     raise << "9: unbalanced '[' for recipe\n" << end();
 162     return false;
 163   }
 164   // End next_instruction(curr)
@@ -237,7 +240,7 @@ if ('onhashchange' in window) {
 174   skip_whitespace_and_comments_but_not_newline(in);
 175   string result = out.str();
 176   if (result != "[" && ends_with(result, '['))
-177     raise << "insert a space before '[' in '" << result << "'\n" << end();
+177     raise << "insert a space before '[' in '" << result << "'\n" << end();
 178   return result;
 179 }
 180 
@@ -253,17 +256,17 @@ if ('onhashchange' in window) {
 190 
 191 :(before "End Globals")
 192 // word boundaries
-193 extern const string Terminators("(){}");
+193 extern const string Terminators("(){}");
 194 :(code)
 195 void slurp_word(istream& in, ostream& out) {
 196   char c;
-197   if (has_data(in) && Terminators.find(in.peek()) != string::npos) {
+197   if (has_data(in) && Terminators.find(in.peek()) != string::npos) {
 198     in >> c;
 199     out << c;
 200     return;
 201   }
 202   while (in >> c) {
-203     if (isspace(c) || Terminators.find(c) != string::npos || Ignore.find(c) != string::npos) {
+203     if (isspace(c) || Terminators.find(c) != string::npos || Ignore.find(c) != string::npos) {
 204       in.putback(c);
 205       break;
 206     }
@@ -275,7 +278,7 @@ if ('onhashchange' in window) {
 212   while (true) {
 213     if (!has_data(in)) break;
 214     if (isspace(in.peek())) in.get();
-215     else if (Ignore.find(in.peek()) != string::npos) in.get();
+215     else if (Ignore.find(in.peek()) != string::npos) in.get();
 216     else if (in.peek() == '#') skip_comment(in);
 217     else break;
 218   }
@@ -287,7 +290,7 @@ if ('onhashchange' in window) {
 224     if (!has_data(in)) break;
 225     if (in.peek() == '\n') break;
 226     if (isspace(in.peek())) in.get();
-227     else if (Ignore.find(in.peek()) != string::npos) in.get();
+227     else if (Ignore.find(in.peek()) != string::npos) in.get();
 228     else if (in.peek() == '#') skip_comment(in);
 229     else break;
 230   }
@@ -418,9 +421,9 @@ if ('onhashchange' in window) {
 355 //: this test we can't represent with a scenario
 356 :(code)
 357 void test_parse_comment_terminated_by_eof() {
-358   load("recipe main [\n"
-359        "  a:number <- copy 34\n"
-360        "]\n"
+358   load("recipe main [\n"
+359        "  a:number <- copy 34\n"
+360        "]\n"
 361        "# abc");  // no newline after comment
 362   cerr << ".";  // termination = success
 363 }
@@ -436,12 +439,12 @@ if ('onhashchange' in window) {
 373 //: step on their own toes. But there'll be many occasions later where
 374 //: we'll want to disable the errors.
 375 :(before "End Globals")
-376 bool Disable_redefine_checks = false;
+376 bool Disable_redefine_checks = false;
 377 :(before "End Reset")
-378 Disable_redefine_checks = false;
+378 Disable_redefine_checks = false;
 379 :(code)
 380 bool should_check_for_redefine(const string& recipe_name) {
-381   if (Disable_redefine_checks) return false;
+381   if (Disable_redefine_checks) return false;
 382   return true;
 383 }
 384 
@@ -472,7 +475,7 @@ if ('onhashchange' in window) {
 409   char c;
 410   while (in >> c)
 411     cerr << c;
-412   cerr << "$\n";
+412   cerr << "$\n";
 413   exit(0);
 414 }
 
-- cgit 1.4.1-2-gfad0