diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/.traces/string_literal_with_colons | 8 | ||||
-rw-r--r-- | cpp/010vm | 4 | ||||
-rw-r--r-- | cpp/025name | 5 | ||||
-rw-r--r-- | cpp/029string | 30 | ||||
-rw-r--r-- | cpp/counters.mu | 4 |
5 files changed, 38 insertions, 13 deletions
diff --git a/cpp/.traces/string_literal_with_colons b/cpp/.traces/string_literal_with_colons new file mode 100644 index 00000000..c00ab66a --- /dev/null +++ b/cpp/.traces/string_literal_with_colons @@ -0,0 +1,8 @@ +parse/0: instruction: 30 +parse/0: ingredient: {name: "abc:def/ghi", value: 0, type: 0, properties: ["abc:def/ghi": "literal-string"]} +parse/0: product: {name: "1", value: 0, type: 2-5-8, properties: ["1": "address":"array":"character"]} +new/0: abc:def/ghi -> 0 +after-brace/0: recipe main +after-brace/0: new ... +run/0: instruction main/0 +mem/0: storing 1000 in location 1 diff --git a/cpp/010vm b/cpp/010vm index 2c230c10..c233f127 100644 --- a/cpp/010vm +++ b/cpp/010vm @@ -181,10 +181,6 @@ Next_recipe_number = 1000; // consistent new numbers for each test types.push_back(0); properties[0].second.push_back("dummy"); } - else if (types.empty()) { // hacky test for string - types.push_back(0); - properties[0].second.push_back("literal-string"); - } } reagent::reagent() :value(0), initialized(false) { // The first property is special, so ensure we always have it. diff --git a/cpp/025name b/cpp/025name index 45fdece2..1c73b16a 100644 --- a/cpp/025name +++ b/cpp/025name @@ -40,11 +40,12 @@ void transform_names(const recipe_number r) { // Per-recipe Transforms // map names to addresses for (size_t in = 0; in < inst.ingredients.size(); ++in) { -//? cout << "ingredients\n"; //? 1 +//? cout << "ingredients\n"; //? 2 if (is_raw(inst.ingredients[in])) continue; -//? cout << "ingredient " << inst.ingredients[in].name << '\n'; //? 1 +//? cout << "ingredient " << inst.ingredients[in].name << '\n'; //? 2 if (inst.ingredients[in].name == "default-space") inst.ingredients[in].initialized = true; + assert(!inst.ingredients[in].types.empty()); if (inst.ingredients[in].types[0] // not a literal && !inst.ingredients[in].initialized && inst.ingredients[in].name.find_first_not_of("0123456789-.") != string::npos) { diff --git a/cpp/029string b/cpp/029string index 320337c4..9ca09115 100644 --- a/cpp/029string +++ b/cpp/029string @@ -12,6 +12,12 @@ recipe main [ ] +parse: ingredient: {name: "abc def", value: 0, type: 0, properties: ["abc def": "literal-string"]} +:(scenario "string_literal_with_colons") +recipe main [ + 1:address:array:character <- new [abc:def/ghi] +] ++parse: ingredient: {name: "abc:def/ghi", value: 0, type: 0, properties: ["abc:def/ghi": "literal-string"]} + :(before "End Mu Types Initialization") Type_number["literal-string"] = 0; @@ -21,21 +27,35 @@ if (in.peek() == '[') return slurp_quoted(in); :(code) string slurp_quoted(istream& in) { assert(!in.eof()); - assert(in.get() == '['); + assert(in.peek() == '['); ostringstream out; - int size = 1; + int size = 0; while (!in.eof()) { char c = in.get(); - if (c == '[') ++size; - if (c == ']') --size; - if (size == 0) break; //? cout << c << '\n'; //? 1 out << c; //? cout << out.str() << "$\n"; //? 1 + if (c == '[') ++size; + if (c == ']') --size; + if (size == 0) break; } return out.str(); } +:(after "reagent::reagent(string s)") +//? cout << s[0] << '\n'; //? 1 + if (s[0] == '[') { + assert(s[s.size()-1] == ']'); + // delete [] delimiters + s.erase(0, 1); + s.erase(s.size()-1, s.size()); + name = s; + types.push_back(0); + properties.push_back(pair<string, vector<string> >(name, vector<string>())); + properties.back().second.push_back("literal-string"); + return; + } + :(scenario "string_literal_nested") recipe main [ 1:address:array:character <- new [abc [def]] diff --git a/cpp/counters.mu b/cpp/counters.mu index c3234d38..8cc9a437 100644 --- a/cpp/counters.mu +++ b/cpp/counters.mu @@ -23,9 +23,9 @@ recipe main [ bres:integer <- increment-counter b:address:space, 2:literal ares:integer <- increment-counter a:address:space, 1:literal # check results - $print [Contents of counters a ] + $print [Contents of counters a: ] $print ares:integer - $print [ b ] + $print [ b: ] $print bres:integer $print [ ] |