about summary refs log tree commit diff stats
path: root/013literal_string.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-26 01:19:27 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-26 01:19:27 -0700
commit7bba6e7bb7fd7bfdfc71626a34a08cb96a084b74 (patch)
tree2e053b799990e3f561a178f2a3340e9a131617ad /013literal_string.cc
parent9cc389ce771636c1350c269ef042c47c427ecd28 (diff)
downloadmu-7bba6e7bb7fd7bfdfc71626a34a08cb96a084b74.tar.gz
2282
Switch format for tracing reagents in preparation for trees rather than
arrays of properties.
Diffstat (limited to '013literal_string.cc')
-rw-r--r--013literal_string.cc28
1 files changed, 13 insertions, 15 deletions
diff --git a/013literal_string.cc b/013literal_string.cc
index 569c8613..9f5d003e 100644
--- a/013literal_string.cc
+++ b/013literal_string.cc
@@ -10,13 +10,13 @@
 recipe main [
   1:address:array:character <- copy [abc def]  # copy can't really take a string
 ]
-+parse:   ingredient: {name: "abc def", properties: [_: "literal-string"]}
++parse:   ingredient: {"abc def": "literal-string"}
 
 :(scenario string_literal_with_colons)
 recipe main [
   1:address:array:character <- copy [abc:def/ghi]
 ]
-+parse:   ingredient: {name: "abc:def/ghi", properties: [_: "literal-string"]}
++parse:   ingredient: {"abc:def/ghi": "literal-string"}
 
 :(before "End Mu Types Initialization")
 Type_ordinal["literal-string"] = 0;
@@ -117,10 +117,8 @@ if (s.at(0) == '[') {
   return;
 }
 
-//: Two tweaks to printing literal strings compared to other reagents:
-//:   a) Don't print the string twice in the representation, just put '_' in
-//:   the property list.
-//:   b) Escape newlines in the string to make it more friendly to trace().
+//: Unlike other reagents, escape newlines in literal strings to make them
+//: more friendly to trace().
 
 :(after "string reagent::to_string()")
   if (is_literal_string(*this))
@@ -135,7 +133,7 @@ string emit_literal_string(string name) {
   size_t pos = 0;
   while (pos != string::npos)
     pos = replace(name, "\n", "\\n", pos);
-  return "{name: \""+name+"\", properties: [_: \"literal-string\"]}";
+  return "{\""+name+"\": \"literal-string\"}";
 }
 
 size_t replace(string& str, const string& from, const string& to, size_t n) {
@@ -153,28 +151,28 @@ void strip_last(string& s) {
 recipe main [
   1:address:array:character <- copy [abc [def]]
 ]
-+parse:   ingredient: {name: "abc [def]", properties: [_: "literal-string"]}
++parse:   ingredient: {"abc [def]": "literal-string"}
 
 :(scenario string_literal_escaped)
 recipe main [
   1:address:array:character <- copy [abc \[def]
 ]
-+parse:   ingredient: {name: "abc [def", properties: [_: "literal-string"]}
++parse:   ingredient: {"abc [def": "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"]}
++parse:   ingredient: {"\nabc \[def": "literal-string"}
 
 :(scenario string_literal_and_comment)
 recipe main [
   1:address:array:character <- copy [abc]  # comment
 ]
 +parse: instruction: copy
-+parse:   ingredient: {name: "abc", properties: [_: "literal-string"]}
-+parse:   product: {name: "1", properties: ["1": "address":"array":"character"]}
++parse:   ingredient: {"abc": "literal-string"}
++parse:   product: {"1": <"address" : "array" : "character">}
 # no other ingredients
 $parse: 3
 
@@ -183,7 +181,7 @@ recipe main [
   copy [abc
 def]
 ]
-+parse:   ingredient: {name: "abc\ndef", properties: [_: "literal-string"]}
++parse:   ingredient: {"abc\ndef": "literal-string"}
 
 :(scenario string_literal_can_skip_past_comments)
 recipe main [
@@ -192,10 +190,10 @@ recipe main [
     bar
   ]
 ]
-+parse:   ingredient: {name: "\n    # ']' inside comment\n    bar\n  ", properties: [_: "literal-string"]}
++parse:   ingredient: {"\n    # ']' inside comment\n    bar\n  ": "literal-string"}
 
 :(scenario string_literal_empty)
 recipe main [
   copy []
 ]
-+parse:   ingredient: {name: "", properties: [_: "literal-string"]}
++parse:   ingredient: {"": "literal-string"}