summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Sencha-lang/AST/ImportStatement.cpp42
-rw-r--r--Sencha-lang/AST/ImportStatement.h30
2 files changed, 72 insertions, 0 deletions
diff --git a/Sencha-lang/AST/ImportStatement.cpp b/Sencha-lang/AST/ImportStatement.cpp
new file mode 100644
index 0000000..9f05da0
--- /dev/null
+++ b/Sencha-lang/AST/ImportStatement.cpp
@@ -0,0 +1,42 @@
+/*
+ * ImportStatement.cpp
+ *
+ * Created on: Jan 7, 2013
+ * Author: att
+ */
+
+#include "ImportStatement.h"
+
+ImportStatement::ImportStatement(std::string name_of_module, ContextManager * context_manager) :
+name_of_module(name_of_module), context_manager(context_manager){
+ //Hrum hrum magic
+
+ std::ifstream module_file(name_of_module);
+ std::string module_source_text = "";
+ std::string line;
+ Lexer lexer;
+ vector<Token> tokens;
+ Parser parser(context_manager);
+ if (module_file.is_open())
+ {
+ while ( module_file.good() )
+ {
+ getline (module_file, line);
+ module_source_text += line;
+ tokens = lexer.parse_line(line);
+ parser.add_tokens(tokens);
+ }
+ module_file.close();
+ }
+ import_body = parser.interpret();
+ children.push_back(import_body);
+}
+
+ImportStatement::~ImportStatement() {
+ // TODO Auto-generated destructor stub
+}
+
+SenchaObject ImportStatement::execute()
+{
+ return import_body->execute();
+}
diff --git a/Sencha-lang/AST/ImportStatement.h b/Sencha-lang/AST/ImportStatement.h
new file mode 100644
index 0000000..8472d1a
--- /dev/null
+++ b/Sencha-lang/AST/ImportStatement.h
@@ -0,0 +1,30 @@
+/*
+ * ImportStatement.h
+ *
+ * Created on: Jan 7, 2013
+ * Author: att
+ */
+
+#ifndef IMPORTSTATEMENT_H_
+#define IMPORTSTATEMENT_H_
+
+#include <fstream>
+#include <iostream>
+
+#include "ASTStatement.h"
+#include "../Parser.h"
+#include "../Lexer.h"
+#include "../ContextManager.h"
+
+class ImportStatement: public ASTStatement {
+public:
+ std::string name_of_module;
+ ContextManager * context_manager;
+
+ ImportStatement(std::string name_of_module, ContextManager * context_manager);
+ ProgramNode * import_body;
+ SenchaObject execute();
+ virtual ~ImportStatement();
+};
+
+#endif /* IMPORTSTATEMENT_H_ */