-Subproject commit efe094829e9d5b499cc1ec9d22dca2f74b796210
+Subproject commit 78ac3565dc1814885278bb9afd8844c73a02014b
SingleCharOp(ret);
}
}
- cout << "token: " << ret.type() << endl;
return ret;
}
#include <sstream>
#include <fstream>
#include "dlparser.h"
-#include "sexp.h"
+#include "astprinter.h"
#include "scheme.h"
#include "cork.h"
{
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
+++ /dev/null
-#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)
-{
-}
-
+++ /dev/null
-#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