Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / src / main.cpp
diff options
context:
space:
mode:
1 files changed, 23 insertions, 1 deletions
-rw-r--r--JSImpl/src/main.cpp24
diff --git a/JSImpl/src/main.cpp b/JSImpl/src/main.cpp
index 73f883f..80dcd32 100644
--- a/JSImpl/src/main.cpp
+++ b/JSImpl/src/main.cpp
@@ -1,6 +1,7 @@
#include "Lexer.h"
#include "Parser.h"
#include "ASTPrinter.h"
+#include "ASTInterpreter.h"
#include <iostream>
#define LOG(msg) std::cout << msg << std::endl
#define EXECUTE_TEST(test) std::cout << #test << " "; test();
@@ -198,6 +199,26 @@ void TestParseUnaryExpr()
expr->Accept(p);
}
+void RunParseCalc()
+{
+ IPLVector<Token> tokens;
+ //Tokenize("var a = 0; var b = a + 123;a+b;", tokens);
+ Tokenize("123 + 321", tokens);
+
+ // TODO make actual test :D
+ auto expr = Parse(tokens);
+ ASTPrinter p(std::cout);
+ expr->Accept(p);
+ ASTInterpreter i;
+ std::cout << "Running" << std::endl;
+ auto result = i.Run(expr.get());
+ std::cout << "Stack after run, top to bottom:" << std::endl;
+ while (!result.empty()) {
+ std::cout << result.top() << std::endl;
+ result.pop();
+ }
+}
+
void TestHexNumber()
{
IPLVector<Token> tokens;
@@ -235,7 +256,8 @@ int main()
EXECUTE_TEST(TestHexNumber);
EXECUTE_TEST(TestScientificNotationNumber);
- // TestParseUnaryExpr();
+ //TestParseUnaryExpr();
+ //RunParseCalc();
#if defined(_WIN32)
std::system("pause");
#endif