diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/.traces/convert_names_passes_default_space | 10 | ||||
-rw-r--r-- | cpp/025name | 13 |
2 files changed, 21 insertions, 2 deletions
diff --git a/cpp/.traces/convert_names_passes_default_space b/cpp/.traces/convert_names_passes_default_space new file mode 100644 index 00000000..92479559 --- /dev/null +++ b/cpp/.traces/convert_names_passes_default_space @@ -0,0 +1,10 @@ +parse/0: instruction: 1 +parse/0: ingredient: {name: "0", value: 0, type: 0, properties: [0: literal]} +parse/0: product: {name: "default_space", value: 0, type: 1, properties: [default_space: integer]} +parse/0: product: {name: "x", value: 0, type: 1, properties: [x: integer]} +name/0: assign x 1 +after-brace/0: recipe main +after-brace/0: copy ... +run/0: instruction main/0 +run/0: ingredient 0 is 0 +mem/0: storing in location 0 diff --git a/cpp/025name b/cpp/025name index 24822afb..606f4d2b 100644 --- a/cpp/025name +++ b/cpp/025name @@ -31,7 +31,7 @@ void transform_names(const recipe_number r) { // map names to addresses for (size_t in = 0; in < inst.ingredients.size(); ++in) { //? cout << "ingredient " << inst.ingredients[in].name << '\n'; //? 1 - if (!inst.ingredients[in].types.empty() + if (inst.ingredients[in].name != "default_space" && inst.ingredients[in].types[0] && inst.ingredients[in].name.find_first_not_of("0123456789-.") != string::npos) { if (names.find(inst.ingredients[in].name) == names.end()) { @@ -46,7 +46,8 @@ void transform_names(const recipe_number r) { for (size_t out = 0; out < inst.products.size(); ++out) { //? cout << "product " << out << '/' << inst.products.size() << " " << inst.products[out].name << '\n'; //? 3 //? cout << inst.products[out].types[0] << '\n'; //? 1 - if (!inst.products[out].types.empty() + if (inst.products[out].name != "_" + && inst.products[out].name != "default_space" && inst.products[out].types[0] && inst.products[out].name.find_first_not_of("0123456789-.") != string::npos) { if (names.find(inst.products[out].name) == names.end()) { @@ -68,3 +69,11 @@ recipe main [ ] +name: assign x 1 -name: assign _ 1 + +//: One reserved word that we'll need later. +:(scenario "convert_names_passes_default_space") +recipe main [ + default_space:integer, x:integer <- copy 0:literal +] ++name: assign x 1 +-name: assign default_space 1 |