summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-22 19:19:13 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-22 19:19:13 +0100
commit10f3eaf214babcfeff4ce37bd18c3e6b2296d0e2 (patch)
treef06f74b4d50c13c758b9a17a5eec34ff70a49a99
parent8ef1eb14c59525d55ad3b55786246bb44e204981 (diff)
downloadsencha-lang-10f3eaf214babcfeff4ce37bd18c3e6b2296d0e2.tar.gz
sencha-lang-10f3eaf214babcfeff4ce37bd18c3e6b2296d0e2.tar.bz2
sencha-lang-10f3eaf214babcfeff4ce37bd18c3e6b2296d0e2.tar.xz
sencha-lang-10f3eaf214babcfeff4ce37bd18c3e6b2296d0e2.zip
Almost done!
-rw-r--r--Sencha-lang/AST/ProgramNode.cpp5
-rw-r--r--Sencha-lang/Parser.cpp8
-rw-r--r--Sencha-lang/Tests/TestParser.cpp9
3 files changed, 18 insertions, 4 deletions
diff --git a/Sencha-lang/AST/ProgramNode.cpp b/Sencha-lang/AST/ProgramNode.cpp
index 43369f0..0a5240a 100644
--- a/Sencha-lang/AST/ProgramNode.cpp
+++ b/Sencha-lang/AST/ProgramNode.cpp
@@ -38,7 +38,10 @@ void ProgramNode::execute_last()
SenchaObject ProgramNode::evaluate_last()
{
- return static_cast<ASTStatement * >(children[children.size() - 1])->evaluate();
+ std::cout << "Program evaluates last statement:";
+ SenchaObject result = (children[children.size() - 1])->evaluate();
+ std::cout << "It's value is: " << result.repr() << std::endl;
+ return result;
}
std::string ProgramNode::debug()
diff --git a/Sencha-lang/Parser.cpp b/Sencha-lang/Parser.cpp
index 8a367b2..962bcb8 100644
--- a/Sencha-lang/Parser.cpp
+++ b/Sencha-lang/Parser.cpp
@@ -18,13 +18,17 @@ Parser::~Parser()
void Parser::erase_all()
{
- tree.delete_all_children();
+ /*tree.delete_all_children();
tree.root = new ProgramNode();
+ */
+
error_message = "***ERRORS DURING PARSING***\n";
position_in_stream = 0;
in_statement = false;
- program = static_cast<ProgramNode *>(tree.root);
+ this->token_stream = vector<Token>();
+ delete program;
+ program = new ProgramNode();
}
diff --git a/Sencha-lang/Tests/TestParser.cpp b/Sencha-lang/Tests/TestParser.cpp
index a65bb71..649d576 100644
--- a/Sencha-lang/Tests/TestParser.cpp
+++ b/Sencha-lang/Tests/TestParser.cpp
@@ -23,14 +23,21 @@ std::string TestParser::test_parsing_and_evaluating_logical_expressions()
Lexer lexer;
Context context;
Parser parser(&context);
+ ASTInspector inspector;
for(auto logical_case : logical_inputs)
{
auto tokens = lexer.parse_line(logical_case.first);
parser.add_tokens(tokens);
- auto value = parser.program->evaluate();
+ cout << parser.show_tokens();
+ parser.interpret();
+ inspector.visit(parser.program);
+ std::cout << inspector.get_report();
+ inspector.forget_everything();
+ SenchaObject value = parser.program->evaluate();
parser.erase_all();
muu_assert("Logical value isn't correct", value.truthy == logical_case.second);
}
+
return test_report;
}