diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-02-16 17:08:49 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-02-16 17:08:49 -0800 |
commit | f1e1cac414c34449113ca7196ceb82cbcbb2517f (patch) | |
tree | 1b5faad9841e501fee69d991497929b26c59cc15 /cpp | |
parent | 5963dacdb07100af6662a5b0366b3fca18e4c2fb (diff) | |
download | mu-f1e1cac414c34449113ca7196ceb82cbcbb2517f.tar.gz |
768
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/002main.cc | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/cpp/002main.cc b/cpp/002main.cc index f042dbd5..1476150c 100644 --- a/cpp/002main.cc +++ b/cpp/002main.cc @@ -154,13 +154,28 @@ void compile(string form) { istringstream in(form); in >> std::noskipws; - if (next_word(in) != "recipe") - raise << "top-level forms must be of the form 'recipe _name_ [ _instruction_ ... ]'"; + string _recipe = next_word(in); +//? cout << _recipe << '\n'; //? 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 << "$\n"; //? 1 if (recipe_name.empty()) raise << "empty recipe name in " << form << '\n'; int r = Recipe_number[recipe_name] = Next_recipe_number++; + +//? string foo = next_word(in); //? 1 +//? cout << '^' << foo << "$ (" << foo.size() << ")\n"; //? 1 + if (next_word(in) != "[") + raise << "recipe body must begin with '['\n"; + + skip_newlines(in); + + instruction curr; +//? while (next_instruction(in, &curr)) { //? 1 +//? Recipe[r].step.push_back(curr); //? 1 +//? } //? 1 } bool next_instruction(istream& in, instruction* curr) { @@ -171,8 +186,11 @@ bool next_instruction(istream& in, instruction* curr) { string next_word(istream& in) { ostringstream out; +//? cout << "1: " << (int)in.peek() << '\n'; //? 1 skip_whitespace(in); +//? cout << "2: " << (int)in.peek() << '\n'; //? 1 slurp_word(in, out); +//? cout << "3: " << (int)in.peek() << '\n'; //? 1 //? cout << out.str() << '\n'; //? 1 return out.str(); } @@ -181,7 +199,7 @@ void slurp_word(istream& in, ostream& out) { char c; while (in >> c) { //? cout << c << '\n'; //? 1 - if (isspace(c) && c != '\n' && c != ',') { + if (isspace(c) || c == ',') { //? cout << " space\n"; //? 1 in.putback(c); break; @@ -191,8 +209,10 @@ void slurp_word(istream& in, ostream& out) { } void skip_whitespace(istream& in) { - while (isspace(in.peek()) && in.peek() != '\n') + while (isspace(in.peek()) && in.peek() != '\n') { +//? cout << "skip\n"; //? 1 in.get(); + } } void skip_newlines(istream& in) { |