]> git.mdlowis.com Git - archive/dlang.git/commitdiff
Modified main to simply print the AST instead of translate it
authorMike D. Lowis <mike@mdlowis.com>
Mon, 5 Mar 2012 19:47:56 +0000 (14:47 -0500)
committerMike D. Lowis <mike@mdlowis.com>
Mon, 5 Mar 2012 19:47:56 +0000 (14:47 -0500)
deps/parse-utils
source/dllexer/dllexer.cpp
source/main.cpp
source/visitors/sexp/sexp.cpp [deleted file]
source/visitors/sexp/sexp.h [deleted file]

index efe094829e9d5b499cc1ec9d22dca2f74b796210..78ac3565dc1814885278bb9afd8844c73a02014b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit efe094829e9d5b499cc1ec9d22dca2f74b796210
+Subproject commit 78ac3565dc1814885278bb9afd8844c73a02014b
index 7a1f6d4a54888dd929cb4500213107a089db8645..96e72c0777eca2e5fab88b0c7592804a881c2157 100644 (file)
@@ -100,7 +100,6 @@ Token DLLexer::next(void)
             SingleCharOp(ret);
         }
     }
-    cout << "token: " << ret.type() << endl;
     return ret;
 }
 
index 2a412a3b78696d391311711670d3c80cc658980b..d9db18d53068599f37e80e079d39b0ebcf0c4852 100644 (file)
@@ -3,7 +3,7 @@
 #include <sstream>
 #include <fstream>
 #include "dlparser.h"
-#include "sexp.h"
+#include "astprinter.h"
 #include "scheme.h"
 #include "cork.h"
 
@@ -20,30 +20,23 @@ int main(int argc, char** argv)
     {
         string input_fname(argv[1]);
         string temp_fname = createTempFileName( input_fname );
+        (void)temp_fname;
         DLParser parser;
-        Scheme* visitor = NULL;
+        ASTPrinter* visitor = NULL;
 
         // Open the input and output files
         ifstream input(input_fname.c_str());
-        ofstream output(temp_fname.c_str());
 
         // Parse the file
         parser.setInput(&input);
 
         // Translate the AST
-        visitor = _new Scheme( parser.parse() );
+        visitor = _new ASTPrinter( parser.parse() );
         visitor->visit();
 
-        // Write to a temp file
-        output << visitor->str();
+        // Write output to screen
         cout << visitor->str();
-        output.close();
 
-        // Compile temp file
-        system(("csc " + temp_fname).c_str());
-
-        // delete temp file
-        remove(temp_fname.c_str());
         delete visitor;
     }
     else
diff --git a/source/visitors/sexp/sexp.cpp b/source/visitors/sexp/sexp.cpp
deleted file mode 100644 (file)
index d0eb266..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "sexp.h"
-
-using namespace std;
-
-string SEXP::str()
-{
-    return stream.str();
-}
-
-void SEXP::beforeVisit(AST* cur, int depth)
-{
-}
-
-void SEXP::afterVisit(AST* cur, int depth)
-{
-    stream << endl;
-}
-
-void SEXP::beforeChildren(AST* cur, int depth)
-{
-    stream << "(" << cur->type() << " " << cur->text();
-}
-
-void SEXP::afterChildren(AST* cur, int depth)
-{
-    stream << ")";
-}
-
-void SEXP::beforeChild(AST* cur, int depth)
-{
-    stream << endl;
-    for(int i = 0; i< depth; i++)
-    {
-        stream << "  ";
-    }
-}
-
-void SEXP::afterChild(AST* cur, int depth)
-{
-}
-
diff --git a/source/visitors/sexp/sexp.h b/source/visitors/sexp/sexp.h
deleted file mode 100644 (file)
index 415fa18..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef SEXP_H
-#define SEXP_H
-
-#include "ivisitor.h"
-#include <iostream>
-#include <sstream>
-
-class SEXP : public IVisitor {
-    protected:
-        ostringstream stream;
-    public:
-        SEXP(AST* root) : IVisitor(root) {};
-        string str();
-    private:
-        void beforeVisit(AST* cur, int depth);
-        void afterVisit(AST* cur, int depth);
-        void beforeChildren(AST* cur, int depth);
-        void afterChildren(AST* cur, int depth);
-        void beforeChild(AST* cur, int depth);
-        void afterChild(AST* cur, int depth);
-};
-
-#endif