summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST/ImportStatement.cpp
blob: 9f05da0e0bbb8a053206f5396f6850596e8fef37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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();
}