From 805d58c6aeeeba3e4989c0eed6781b3861e8fae0 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 25 Jan 2018 22:39:31 -0800 Subject: 4199 --- html/014literal_string.cc.html | 119 ++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 60 deletions(-) (limited to 'html/014literal_string.cc.html') diff --git a/html/014literal_string.cc.html b/html/014literal_string.cc.html index 93cf8607..0d7a82e4 100644 --- a/html/014literal_string.cc.html +++ b/html/014literal_string.cc.html @@ -15,18 +15,17 @@ body { font-size: 12pt; font-family: monospace; color: #aaaaaa; background-color a { color:#eeeeee; text-decoration: none; } a:hover { text-decoration: underline; } * { font-size: 12pt; font-size: 1em; } -.Conceal { color: #4e4e4e; } -.traceContains { color: #008000; } +.cSpecial { color: #008000; } .LineNr { color: #444444; } -.Identifier { color: #c0a020; } .Constant { color: #00a0a0; } +.muRecipe { color: #ff8700; } +.Delimiter { color: #800080; } +.Special { color: #c00000; } +.Identifier { color: #c0a020; } .Normal { color: #aaaaaa; background-color: #080808; padding-bottom: 1px; } .Comment { color: #9090ff; } .Comment a { color:#0000ee; text-decoration:underline; } -.Delimiter { color: #800080; } -.Special { color: #c00000; } -.cSpecial { color: #008000; } -.muRecipe { color: #ff8700; } +.traceContains { color: #008000; } --> @@ -72,13 +71,13 @@ if ('onhashchange' in window) { 9 :(scenarios load) 10 :(scenario string_literal) 11 def main [ - 12 1:address:array:character <- copy [abc def] + 12 1:address:array:character <- copy [abc def] 13 ] 14 +parse: ingredient: {"abc def": "literal-string"} 15 16 :(scenario string_literal_with_colons) 17 def main [ - 18 1:address:array:character <- copy [abc:def/ghi] + 18 1:address:array:character <- copy [abc:def/ghi] 19 ] 20 +parse: ingredient: {"abc:def/ghi": "literal-string"} 21 @@ -97,9 +96,9 @@ if ('onhashchange' in window) { 34 ostringstream out; 35 assert(has_data(in)); assert(in.peek() == '['); out << static_cast<char>(in.get()); // slurp the '[' 36 if (is_code_string(in, out)) - 37 ¦ slurp_quoted_comment_aware(in, out); + 37 slurp_quoted_comment_aware(in, out); 38 else - 39 ¦ slurp_quoted_comment_oblivious(in, out); + 39 slurp_quoted_comment_oblivious(in, out); 40 return out.str(); 41 } 42 @@ -107,15 +106,15 @@ if ('onhashchange' in window) { 44 // brackets) if it contains a newline at the start before any non-whitespace. 45 bool is_code_string(istream& in, ostream& out) { 46 while (has_data(in)) { - 47 ¦ char c = in.get(); - 48 ¦ if (!isspace(c)) { - 49 ¦ ¦ in.putback(c); - 50 ¦ ¦ return false; - 51 ¦ } - 52 ¦ out << c; - 53 ¦ if (c == '\n') { - 54 ¦ ¦ return true; - 55 ¦ } + 47 char c = in.get(); + 48 if (!isspace(c)) { + 49 in.putback(c); + 50 return false; + 51 } + 52 out << c; + 53 if (c == '\n') { + 54 return true; + 55 } 56 } 57 return false; 58 } @@ -125,19 +124,19 @@ if ('onhashchange' in window) { 62 void slurp_quoted_comment_oblivious(istream& in, ostream& out) { 63 int brace_depth = 1; 64 while (has_data(in)) { - 65 ¦ char c = in.get(); - 66 ¦ if (c == '\\') { - 67 ¦ ¦ slurp_one_past_backslashes(in, out); - 68 ¦ ¦ continue; - 69 ¦ } - 70 ¦ out << c; - 71 ¦ if (c == '[') ++brace_depth; - 72 ¦ if (c == ']') --brace_depth; - 73 ¦ if (brace_depth == 0) break; + 65 char c = in.get(); + 66 if (c == '\\') { + 67 slurp_one_past_backslashes(in, out); + 68 continue; + 69 } + 70 out << c; + 71 if (c == '[') ++brace_depth; + 72 if (c == ']') --brace_depth; + 73 if (brace_depth == 0) break; 74 } 75 if (!has_data(in) && brace_depth > 0) { - 76 ¦ raise << "unbalanced '['\n" << end(); - 77 ¦ out.clear(); + 76 raise << "unbalanced '['\n" << end(); + 77 out.clear(); 78 } 79 } 80 @@ -145,23 +144,23 @@ if ('onhashchange' in window) { 82 void slurp_quoted_comment_aware(istream& in, ostream& out) { 83 char c; 84 while (in >> c) { - 85 ¦ if (c == '\\') { - 86 ¦ ¦ slurp_one_past_backslashes(in, out); - 87 ¦ ¦ continue; - 88 ¦ } - 89 ¦ if (c == '#') { - 90 ¦ ¦ out << c; - 91 ¦ ¦ while (has_data(in) && in.peek() != '\n') out << static_cast<char>(in.get()); - 92 ¦ ¦ continue; - 93 ¦ } - 94 ¦ if (c == '[') { - 95 ¦ ¦ in.putback(c); - 96 ¦ ¦ // recurse - 97 ¦ ¦ out << slurp_quoted(in); - 98 ¦ ¦ continue; - 99 ¦ } -100 ¦ out << c; -101 ¦ if (c == ']') return; + 85 if (c == '\\') { + 86 slurp_one_past_backslashes(in, out); + 87 continue; + 88 } + 89 if (c == '#') { + 90 out << c; + 91 while (has_data(in) && in.peek() != '\n') out << static_cast<char>(in.get()); + 92 continue; + 93 } + 94 if (c == '[') { + 95 in.putback(c); + 96 // recurse + 97 out << slurp_quoted(in); + 98 continue; + 99 } +100 out << c; +101 if (c == ']') return; 102 } 103 raise << "unbalanced '['\n" << end(); 104 out.clear(); @@ -183,7 +182,7 @@ if ('onhashchange' in window) { 120 121 :(after "string to_string(const reagent& r)") 122 if (is_literal_text(r)) -123 ¦ return emit_literal_string(r.name); +123 return emit_literal_string(r.name); 124 125 :(code) 126 bool is_literal_text(const reagent& x) { @@ -193,14 +192,14 @@ if ('onhashchange' in window) { 130 string emit_literal_string(string name) { 131 size_t pos = 0; 132 while (pos != string::npos) -133 ¦ pos = replace(name, "\n", "\\n", pos); +133 pos = replace(name, "\n", "\\n", pos); 134 return "{\""+name+"\": \"literal-string\"}"; 135 } 136 137 size_t replace(string& str, const string& from, const string& to, size_t n) { 138 size_t result = str.find(from, n); 139 if (result != string::npos) -140 ¦ str.replace(result, from.length(), to); +140 str.replace(result, from.length(), to); 141 return result; 142 } 143 @@ -224,34 +223,34 @@ if ('onhashchange' in window) { 161 // backslashes both to escape quote characters and also as a notation for 162 // unprintable characters like '\n'. 163 while (has_data(in)) { -164 ¦ char c = in.get(); -165 ¦ out << c; -166 ¦ if (c != '\\') break; +164 char c = in.get(); +165 out << c; +166 if (c != '\\') break; 167 } 168 } 169 170 :(scenario string_literal_nested) 171 def main [ -172 1:address:array:character <- copy [abc [def]] +172 1:address:array:character <- copy [abc [def]] 173 ] 174 +parse: ingredient: {"abc [def]": "literal-string"} 175 176 :(scenario string_literal_escaped) 177 def main [ -178 1:address:array:character <- copy [abc \[def] +178 1:address:array:character <- copy [abc \[def] 179 ] 180 +parse: ingredient: {"abc [def": "literal-string"} 181 182 :(scenario string_literal_escaped_twice) 183 def main [ -184 1:address:array:character <- copy [ +184 1:address:array:character <- copy [ 185 abc \\[def] 186 ] 187 +parse: ingredient: {"\nabc \[def": "literal-string"} 188 189 :(scenario string_literal_and_comment) 190 def main [ -191 1:address:array:character <- copy [abc] # comment +191 1:address:array:character <- copy [abc] # comment 192 ] 193 +parse: --- defining main 194 +parse: instruction: copy @@ -269,8 +268,8 @@ if ('onhashchange' in window) { 206 :(scenario string_literal_can_skip_past_comments) 207 def main [ 208 copy [ -209 ¦ # ']' inside comment -210 ¦ bar +209 # ']' inside comment +210 bar 211 ] 212 ] 213 +parse: ingredient: {"\n # ']' inside comment\n bar\n ": "literal-string"} -- cgit 1.4.1-2-gfad0