From c712c2717f7ee14a258b4299d5bda3577b4c13cb Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 13 Jun 2015 23:08:46 -0700 Subject: 1557 More concise traces for literal strings. --- 010vm.cc | 8 ++++++++ 013literal_string.cc | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/010vm.cc b/010vm.cc index ffc92c60..5be84982 100644 --- a/010vm.cc +++ b/010vm.cc @@ -203,6 +203,9 @@ reagent::reagent() :value(0), initialized(false) { properties.push_back(pair >("", vector())); } string reagent::to_string() const { + if (!properties.at(0).second.empty() && properties.at(0).second.at(0) == "literal-string") { + return emit_literal_string(name); + } ostringstream out; out << "{name: \"" << name << "\""; if (!properties.empty()) { @@ -218,9 +221,14 @@ string reagent::to_string() const { } } out << "}"; +//? if (properties.at(0).second.empty()) cerr << out.str(); //? 1 return out.str(); } +string emit_literal_string(string name) { + return "{name: \""+name+"\", properties: [_: \"literal-string\"]}"; +} + string instruction::to_string() const { if (is_label) return label; ostringstream out; diff --git a/013literal_string.cc b/013literal_string.cc index b31bc702..41644b1c 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: ["abc def": "literal-string"]} ++parse: ingredient: {name: "abc def", properties: [_: "literal-string"]} :(scenario string_literal_with_colons) recipe main [ 1:address:array:character <- copy [abc:def/ghi] ] -+parse: ingredient: {name: "abc:def/ghi", properties: ["abc:def/ghi": "literal-string"]} ++parse: ingredient: {name: "abc:def/ghi", properties: [_: "literal-string"]} :(before "End Mu Types Initialization") Type_number["literal-string"] = 0; @@ -73,20 +73,20 @@ string slurp_quoted(istream& in) { recipe main [ 1:address:array:character <- copy [abc [def]] ] -+parse: ingredient: {name: "abc [def]", properties: ["abc [def]": "literal-string"]} ++parse: ingredient: {name: "abc [def]", properties: [_: "literal-string"]} :(scenario string_literal_escaped) recipe main [ 1:address:array:character <- copy [abc \[def] ] -+parse: ingredient: {name: "abc [def", properties: ["abc [def": "literal-string"]} ++parse: ingredient: {name: "abc [def", properties: [_: "literal-string"]} :(scenario string_literal_and_comment) recipe main [ 1:address:array:character <- copy [abc] # comment ] +parse: instruction: copy -+parse: ingredient: {name: "abc", properties: ["abc": "literal-string"]} ++parse: ingredient: {name: "abc", properties: [_: "literal-string"]} +parse: product: {name: "1", properties: ["1": "address":"array":"character"]} # no other ingredients $parse: 3 -- cgit 1.4.1-2-gfad0