From fc52705f4956df9a756b902b187f31799c1451a4 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 19 Jun 2015 13:37:11 -0700 Subject: 1598 Some tests weren't actually running for the past 5 days. Performed 5 why's. --- 013literal_string.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to '013literal_string.cc') diff --git a/013literal_string.cc b/013literal_string.cc index 60fbd266..f8445c26 100644 --- a/013literal_string.cc +++ b/013literal_string.cc @@ -62,10 +62,12 @@ bool code_string(istream& in, ostringstream& out) { // Read a regular string. Regular strings can only contain other regular // strings. -void slurp_quoted_comment_oblivious(istream& in, ostream& out) { +void slurp_quoted_comment_oblivious(istream& in, ostringstream& out) { +//? cerr << "comment oblivious\n"; //? 1 int brace_depth = 1; while (!in.eof()) { char c = in.get(); +//? cerr << '%' << (int)c << ' ' << brace_depth << ": " << out.str() << "%$\n"; //? 1 //? cout << (int)c << ": " << brace_depth << '\n'; //? 2 if (c == '\\') { out << static_cast(in.get()); @@ -84,9 +86,15 @@ void slurp_quoted_comment_oblivious(istream& in, ostream& out) { } // Read a code string. Code strings can contain either code or regular strings. -void slurp_quoted_comment_aware(istream& in, ostream& out) { +void slurp_quoted_comment_aware(istream& in, ostringstream& out) { +//? cerr << "comment aware\n"; //? 1 char c; while (in >> c) { +//? cerr << '^' << (int)c << ": " << out.str() << "$\n"; //? 1 + if (c == '\\') { + out << static_cast(in.get()); + continue; + } if (c == '#') { out << c; while (!in.eof() && in.peek() != '\n') out << static_cast(in.get()); @@ -99,8 +107,10 @@ void slurp_quoted_comment_aware(istream& in, ostream& out) { continue; } out << c; - if (c == ']') break; + if (c == ']') return; } + raise << "unbalanced '['\n"; + out.clear(); } :(after "reagent::reagent(string s)") @@ -154,6 +164,13 @@ recipe main [ ] +parse: ingredient: {name: "abc [def", properties: [_: "literal-string"]} +:(scenario string_literal_escaped_comment_aware) +recipe main [ + 1:address:array:character <- copy [ +abc \\\[def] +] ++parse: ingredient: {name: "\nabc \[def", properties: [_: "literal-string"]} + :(scenario string_literal_and_comment) recipe main [ 1:address:array:character <- copy [abc] # comment -- cgit 1.4.1-2-gfad0