diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-03-14 20:45:54 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-03-14 20:45:54 -0700 |
commit | 7c610028c1f701f587d9e4ad12d439ac34833d83 (patch) | |
tree | 77a259b7780b8a37de2fd91a1c199df55edae5a3 /cpp | |
parent | 064a1c0aca0b76843ae767421d70d2791f50335b (diff) | |
download | mu-7c610028c1f701f587d9e4ad12d439ac34833d83.tar.gz |
919 - c++: run .mu files from commandline
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/000organization | 19 | ||||
-rw-r--r-- | cpp/011load | 9 | ||||
-rw-r--r-- | cpp/x.mu | 5 |
3 files changed, 29 insertions, 4 deletions
diff --git a/cpp/000organization b/cpp/000organization index ba82dd52..f410fcd9 100644 --- a/cpp/000organization +++ b/cpp/000organization @@ -97,9 +97,26 @@ int main(int argc, char* argv[]) { if (argc > 1) { // Commandline Options + if (!is_equal(argv[1], "test")) { + setup(); + for (int i = 1; i < argc; ++i) { + ifstream fin(argv[i]); + while (!fin.eof()) add_recipe(fin); + fin.close(); + } + } } - setup(); +//? setup(); +//? for (unordered_map<string, int>::iterator p = Recipe_number.begin(); p != Recipe_number.end(); ++p) { //? 1 +//? cout << p->first << ": " << p->second << '\n'; //? 1 +//? } //? 1 + recipe_number r = Recipe_number[string("main")]; +//? cout << "recipe " << r << '\n'; //? 1 +//? START_TRACING_UNTIL_END_OF_SCOPE //? 1 +//? DUMP(""); //? 1 + if (r) run(r); + dump_memory(); return 0; // End Main } diff --git a/cpp/011load b/cpp/011load index da8dd3ae..ac41ab44 100644 --- a/cpp/011load +++ b/cpp/011load @@ -16,20 +16,23 @@ int add_recipes(string form) { return result; } -int add_recipe(istringstream& in) { +int add_recipe(istream& in) { in >> std::noskipws; skip_comments_and_newlines(in); string _recipe = next_word(in); +//? cout << _recipe; //? 1 if (_recipe != "recipe") raise << "top-level forms must be of the form 'recipe _name_ [ _instruction_ ... ]'\n"; string recipe_name = next_word(in); +//? cout << "recipe name: ^" << recipe_name << "$\n"; //? 1 if (recipe_name.empty()) - raise << "empty recipe name in " << in.str() << '\n'; + raise << "empty recipe name\n"; +//? 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]; -//? cout << recipe_name << ": adding recipe " << r << '\n'; //? 2 +//? cout << recipe_name << ": adding recipe " << r << '\n'; //? 3 if (next_word(in) != "[") raise << "recipe body must begin with '['\n"; diff --git a/cpp/x.mu b/cpp/x.mu new file mode 100644 index 00000000..0d40a4a7 --- /dev/null +++ b/cpp/x.mu @@ -0,0 +1,5 @@ +recipe main [ + 12:integer <- copy 1:literal + 13:integer <- copy 3:literal + 11:integer <- add 12:integer, 13:integer +] |