summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-22 20:15:34 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2012-12-22 20:15:34 +0100
commit89e84f0a83c1716a9620e449f2bc734b9af2b24e (patch)
treeb18530233b417e9441ab07fc2fceecfe09ab540f
parent10f3eaf214babcfeff4ce37bd18c3e6b2296d0e2 (diff)
downloadsencha-lang-89e84f0a83c1716a9620e449f2bc734b9af2b24e.tar.gz
sencha-lang-89e84f0a83c1716a9620e449f2bc734b9af2b24e.tar.bz2
sencha-lang-89e84f0a83c1716a9620e449f2bc734b9af2b24e.tar.xz
sencha-lang-89e84f0a83c1716a9620e449f2bc734b9af2b24e.zip
Logical expressions are successfully implemented.
-rw-r--r--Sencha-lang/AST/ProgramNode.cpp3
-rw-r--r--Sencha-lang/Tests/TestParser.cpp11
2 files changed, 4 insertions, 10 deletions
diff --git a/Sencha-lang/AST/ProgramNode.cpp b/Sencha-lang/AST/ProgramNode.cpp
index 0a5240a..d22de22 100644
--- a/Sencha-lang/AST/ProgramNode.cpp
+++ b/Sencha-lang/AST/ProgramNode.cpp
@@ -38,9 +38,8 @@ void ProgramNode::execute_last()
SenchaObject ProgramNode::evaluate_last()
{
- 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;
}
diff --git a/Sencha-lang/Tests/TestParser.cpp b/Sencha-lang/Tests/TestParser.cpp
index 649d576..3f432c9 100644
--- a/Sencha-lang/Tests/TestParser.cpp
+++ b/Sencha-lang/Tests/TestParser.cpp
@@ -8,12 +8,12 @@
#include "TestParser.h"
TestParser::TestParser() {
- // TODO Auto-generated constructor stub
+
}
TestParser::~TestParser() {
- // TODO Auto-generated destructor stub
+
}
std::string TestParser::test_parsing_and_evaluating_logical_expressions()
@@ -23,16 +23,11 @@ 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);
- 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);
@@ -53,7 +48,7 @@ std::vector<TestParser::InputOutputPair> TestParser::prepare_logical_input()
logical_inputs.push_back(InputOutputPair("true or false", true));
logical_inputs.push_back(InputOutputPair("true or true", true));
logical_inputs.push_back(InputOutputPair("(true or false) and (true or false)", true));
- logical_inputs.push_back(InputOutputPair("7 + 2 > 55 or 4-5 == -1", true));
+ logical_inputs.push_back(InputOutputPair("7 + 2 > 55 or 6-5 == 1", true));
return logical_inputs;
}