diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-28 11:56:41 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-28 11:56:41 -0700 |
commit | 6aae42ba95a81e4abbfd9512ed948619c2d67141 (patch) | |
tree | 8a514586c1dd7614e6e32ccf6a35ace52fa9e532 | |
parent | 23fd54f120e7256ef3468721aa0c664985751d18 (diff) | |
download | mu-6aae42ba95a81e4abbfd9512ed948619c2d67141.tar.gz |
1498
Cleaner to delegate as much as possible to slurp_quoted.
-rw-r--r-- | 050scenario.cc | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/050scenario.cc b/050scenario.cc index f14d8782..bb828636 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -524,18 +524,30 @@ void run_mu_scenario(const string& form) { string slurp_quoted_ignoring_comments(istream& in) { assert(in.get() == '['); // drop initial '[' - int brace_depth = 1; char c; ostringstream out; while (in >> c) { -//? cerr << c << '\n'; //? 2 - // Still can't handle scenarios inside strings inside scenarios.. - if (brace_depth == 1 && c == '#') { in.putback(c); skip_comment(in); continue; } - if (c == '[') ++brace_depth; - if (c == ']') --brace_depth; - if (brace_depth == 0) break; // drop final ']' +//? cerr << c << '\n'; //? 3 + if (c == '#') { + // skip comment + in.putback(c); + skip_comment(in); + continue; + } + if (c == '[') { + // nested strings won't detect comments + // can't yet handle scenarios inside strings inside scenarios.. + in.putback(c); + out << slurp_quoted(in); +//? cerr << "snapshot: ^" << out.str() << "$\n"; //? 1 + continue; + } + if (c == ']') { + // must be at the outermost level; drop final ']' + break; + } out << c; } -//? cerr << "done\n"; //? 1 +//? cerr << "done\n"; //? 2 return out.str(); } |