about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-23 12:45:39 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-23 12:45:39 -0700
commit7002b26a64b0ec5ce5a6002eb94da8dd8303e8b1 (patch)
tree5748a1121e8822adb01c5003ce1c7db5531f3998
parent60f68dcf1ee09b7fb578516437a1e4c726d30b1f (diff)
downloadmu-7002b26a64b0ec5ce5a6002eb94da8dd8303e8b1.tar.gz
1436
-rw-r--r--041name.cc3
-rw-r--r--072scenario_screen.cc4
-rw-r--r--075scenario_keyboard.cc4
3 files changed, 8 insertions, 3 deletions
diff --git a/041name.cc b/041name.cc
index 300a9c60..24ba4e00 100644
--- a/041name.cc
+++ b/041name.cc
@@ -125,9 +125,6 @@ bool is_raw(const reagent& r) {
 bool is_special_name(const string& s) {
   if (s == "_") return true;
   if (s == "0") return true;
-  // tests will use these in later layers even though tests will mostly use numeric addresses
-  if (s == "screen") return true;
-  if (s == "keyboard") return true;
   // End is_special_name Cases
   return false;
 }
diff --git a/072scenario_screen.cc b/072scenario_screen.cc
index e7c6fb49..e0f9a147 100644
--- a/072scenario_screen.cc
+++ b/072scenario_screen.cc
@@ -53,6 +53,10 @@ scenario screen-in-scenario-error [
 ]
 +warn: expected screen location (0, 0) to contain 98 ('b') instead of 97 ('a')
 
+//: allow naming just for 'screen'
+:(before "End is_special_name Cases")
+if (s == "screen") return true;
+
 :(before "End Globals")
 // Scenarios may not define default-space, so they should fit within the
 // initial area of memory reserved for tests. We'll put the predefined
diff --git a/075scenario_keyboard.cc b/075scenario_keyboard.cc
index 31c10e82..363b3afd 100644
--- a/075scenario_keyboard.cc
+++ b/075scenario_keyboard.cc
@@ -30,6 +30,10 @@ const long long int KEYBOARD = Next_predefined_global_for_scenarios++;
 :(before "End Predefined Scenario Locals In Run")
 Name[tmp_recipe.at(0)]["keyboard"] = KEYBOARD;
 
+//: allow naming just for 'keyword'
+:(before "End is_special_name Cases")
+if (s == "keyboard") return true;
+
 :(before "End Rewrite Instruction(curr)")
 // rewrite `assume-keyboard string` to
 //   ```
ghlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
//: Everything this project/binary supports.
//: This should give you a sense for what to look forward to in later layers.

:(before "End Commandline Parsing")
if (argc <= 1 || is_equal(argv[1], "--help")) {
  // this is the functionality later layers will provide
  // currently no automated tests for commandline arg parsing
  cerr << "To load files and run 'main':\n"
       << "  mu file1.mu file2.mu ...\n"
       << "To run all tests:\n"
       << "  mu test\n"
       << "To load files and then run all tests:\n"
       << "  mu test file1.mu file2.mu ...\n"
       ;
  return 0;
}

//:: Helper function used by the above fragment of code (and later layers too,
//:: who knows?).
//: The :(code) directive appends function definitions to the end of the
//: project. Regardless of where functions are defined, we can call them
//: anywhere we like as long as we format the function header in a specific
//: way: put it all on a single line without indent, end the line with ') {'
//: and no trailing whitespace. As long as functions uniformly start this
//: way, our makefile contains a little command to automatically generate
//: declarations for them.
:(code)
bool is_equal(char* s, const char* lit) {
  return strncmp(s, lit, strlen(lit)) == 0;
}

:(before "End Includes")
#include<iostream>
using std::istream;
using std::ostream;
using std::iostream;
using std::cin;
using std::cout;
using std::cerr;

#include<cstring>
#include<string>
using std::string;
const size_t NOT_FOUND = string::npos;