about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-07-03 10:06:07 -0700
committerKartik Agaram <vc@akkartik.com>2018-07-03 10:06:07 -0700
commit7c71860b87711531f1fd590a9768603a01dc4b18 (patch)
tree80e55df64e39864f0c3f11c0ae5c781fa91d6044 /subx
parentc07651f8ec5492fa9ac90ef78f09b89630447908 (diff)
downloadmu-7c71860b87711531f1fd590a9768603a01dc4b18.tar.gz
4307
Undo 4306.
Diffstat (limited to 'subx')
-rw-r--r--subx/021translate.cc94
1 files changed, 4 insertions, 90 deletions
diff --git a/subx/021translate.cc b/subx/021translate.cc
index ca207329..e43ea894 100644
--- a/subx/021translate.cc
+++ b/subx/021translate.cc
@@ -2,102 +2,16 @@
 //: We're going to question every notion, including "Assembly language" and
 //: "compiler".
 //: Motto: Abstract nothing, check everything.
-
-//: Workflow: read 'source' file into memory. Run a series of transforms on
-//: it, each of which modifies some parts of it and leaves untouched what it
-//: doesn't understand. Write the final state to an ELF binary.
-:(before "End Main")
-if (is_equal(argv[1], "translate")) {
-  assert(argc > 3);
-  program p;
-  parse(argv[2], p);
-  transform(p);
-  dump_elf(p, argv[3]);
-}
-
-//: The data structure we'll use to manage state between transforms, and the
-//: file format that will reify it.
-:(before "End Types")
-struct program {
-  vector<recipe> recipes;
-  vector<global> globals;
-  program() { clear(); }
-  void clear() { recipes.clear();  globals.clear(); }
-};
-//: recipes start with a line of the format:
-//:   -- <recipe_name> : <words> <of> <metadata>
-struct recipe {
-  string name;
-  vector<string> metadata;
-  vector<instruction> instructions;
-};
-//: instructions are lines of the format:
-//:   <word1> <word2> <word3> ... : <metadata_word1> <metadata_word2> ...
-struct instruction {
-  vector<string> words;
-  vector<string> metadata;
-};
-//: comment characters are '#'; everything after them is discarded
-//: everything after ':' is metadata until a comment or end-of-line
-
-struct global {
-  //: todo: how to represent global variables?
-  //: idea: can only contain scalars, usually for tracking state of different
-  //: memory allocators.
-};
-
-//:: parse
-
-:(code)
-void parse(const char* filename, program& out) {
-  ifstream fin(filename);
-  while (has_data(fin)) {
-    string line_data;
-    getline(fin, line_data);
-    istringstream line(line_data);
-    while (has_data(line)) {
-      string word;
-      line >> word;
-      if (word == "--") {
-        program.recipes.
-    }
-  }
-}
-
-string next_word(istream& in) {
-  skip_whitespace_and_comments(in);
-  string result;
-  in >> result;
-  return result;
-}
-
-void skip_whitespace_and_comments(istream& in) {
-  while (true) {
-    char c = in.peek();
-    if (isspace(c)) { in.get();  continue; }
-    else if (c == '#') skip_comment(in);
-    else return;
-  }
-}
-
-void skip_comment(istream& in) {
-  assert(in.peek() == '#');
-  char c = '\0';
-  do {
-    in >> c;
-  } while (c != '\n');
-}
-
-
-//:: transform
+//:
+//: Workflow: read 'source' file as a single string. Run a series of
+//: transforms on it, each converting to a new string. The final string should
+//: be just machine code and comments, suitable to pass to load_program().
 
 :(before "End Types")
 typedef void (*transform_fn)(const string& input, string& output);
 :(before "End Globals")
 vector<transform_fn> Transform;
 
-//:: dump_elf
-
 :(before "End Includes")
 const int START = 0x08048000;
 :(before "End Main")