diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/011load | 10 | ||||
-rw-r--r-- | cpp/012transform | 3 | ||||
-rw-r--r-- | cpp/013literal_string | 2 | ||||
-rw-r--r-- | cpp/014types | 2 | ||||
-rw-r--r-- | cpp/020run | 12 | ||||
-rw-r--r-- | cpp/040brace | 9 | ||||
-rw-r--r-- | cpp/041name | 2 |
7 files changed, 18 insertions, 22 deletions
diff --git a/cpp/011load b/cpp/011load index 3dea0d66..c643a92e 100644 --- a/cpp/011load +++ b/cpp/011load @@ -1,6 +1,6 @@ -//: It's often convenient to express recipes in a textual fashion. +//: Phase 1 of running mu code: load it from a textual representation. -:(scenarios add_recipes) +:(scenarios load) :(scenario first_recipe) recipe main [ 1:integer <- copy 23:literal @@ -10,13 +10,13 @@ recipe main [ +parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} :(code) -vector<recipe_number> add_recipes(string form) { +vector<recipe_number> load(string form) { istringstream in(form); in >> std::noskipws; - return add_recipes(in); + return load(in); } -vector<recipe_number> add_recipes(istream& in) { +vector<recipe_number> load(istream& in) { vector<recipe_number> result; while (!in.eof()) { skip_comments_and_newlines(in); diff --git a/cpp/012transform b/cpp/012transform index bb61c6e0..59b87e69 100644 --- a/cpp/012transform +++ b/cpp/012transform @@ -1,5 +1,4 @@ -//: Once a set of recipes is loaded, it can be filtered through an extensible -//: list of 'transforms'. +//: Phase 2: Filter loaded recipes through an extensible list of 'transforms'. //: //: The hope is that this framework of transform tools will provide a //: deconstructed alternative to conventional compilers. diff --git a/cpp/013literal_string b/cpp/013literal_string index 965f3f60..008f95ad 100644 --- a/cpp/013literal_string +++ b/cpp/013literal_string @@ -5,7 +5,7 @@ //: imagine that 'recipe' might one day itself be defined in mu, doing its own //: parsing. -:(scenarios add_recipes) +:(scenarios load) :(scenario "string_literal") recipe main [ 1:address:array:character <- new [abc def] diff --git a/cpp/014types b/cpp/014types index 1a600c4c..755ae78d 100644 --- a/cpp/014types +++ b/cpp/014types @@ -1,6 +1,6 @@ //: Textual form for types. -:(scenarios "add_recipes") +:(scenarios "load") :(scenario "container") container foo [ x:integer diff --git a/cpp/020run b/cpp/020run index 3e993f95..a9afb460 100644 --- a/cpp/020run +++ b/cpp/020run @@ -1,4 +1,4 @@ -//: Once a recipe is loaded, we need to run it. +//: Phase 3: Start running a loaded and transformed recipe. //: //: So far we've seen recipes as lists of instructions, and instructions point //: at other recipes. To kick things off mu needs to know how to run certain @@ -101,7 +101,7 @@ inline bool done(routine& rr) { :(before "End Commandline Parsing") if (argc > 1) { for (int i = 1; i < argc; ++i) { - load(argv[i]); + load_and_transform(argv[i]); } } @@ -118,14 +118,14 @@ if (!Run_tests) { } :(code) -void load(string filename) { +void load_and_transform(string filename) { ifstream fin(filename.c_str()); if (!fin) { raise << "no such file " << filename << '\n'; return; } fin >> std::noskipws; - add_recipes(fin); + load(fin); transform_all(); fin.close(); // freeze everything so it doesn't get cleared by tests @@ -135,12 +135,12 @@ void load(string filename) { //:: On startup, load everything in core.mu :(before "End Load Recipes") -load("core.mu"); +load_and_transform("core.mu"); :(code) // helper for tests void run(string form) { - vector<recipe_number> tmp = add_recipes(form); + vector<recipe_number> tmp = load(form); transform_all(); run(tmp.front()); } diff --git a/cpp/040brace b/cpp/040brace index 75dbf457..e79f6100 100644 --- a/cpp/040brace +++ b/cpp/040brace @@ -19,7 +19,7 @@ //: benefits of the control-flow primitives we're used to in other languages, //: like 'if', 'while', 'for', etc. -:(scenarios transform_test) +:(scenarios transform) :(scenario "brace_conversion") recipe main [ { @@ -160,12 +160,9 @@ size_t matching_brace(size_t index, const list<pair<int, size_t> >& braces) { } // temporarily suppress run -void transform_test(string form) { -//? cout << "AAA transform_test {\n"; //? 1 - add_recipes(form); -//? cout << "AAA done adding recipes\n"; //? 1 +void transform(string form) { + load(form); transform_all(); -//? cout << "AAA }\n"; //? 1 } //: Make sure these pseudo recipes get consistent numbers in all tests, even diff --git a/cpp/041name b/cpp/041name index f97acd70..791e2227 100644 --- a/cpp/041name +++ b/cpp/041name @@ -163,7 +163,7 @@ if (inst.operation == Recipe_number["get"] } //: this test is actually illegal so can't call run -:(scenarios transform_test) +:(scenarios transform) :(scenario "convert_names_handles_containers") recipe main [ a:point <- copy 0:literal |