about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-20 20:33:16 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-20 20:33:16 -0700
commitad68bbce689969c4b0483a148c2a5260e9256fa7 (patch)
treec01396c8ec4361de14e8baf27fd91e43c418bb39
parentfc55fea025bdb1c6945e6812d49a6d41e8f3c062 (diff)
downloadmu-ad68bbce689969c4b0483a148c2a5260e9256fa7.tar.gz
960
-rw-r--r--cpp/.traces/convert_names_passes_default_space10
-rw-r--r--cpp/025name13
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