Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / src / main.cpp
diff options
context:
space:
mode:
1 files changed, 17 insertions, 16 deletions
-rw-r--r--JSImpl/src/main.cpp33
diff --git a/JSImpl/src/main.cpp b/JSImpl/src/main.cpp
index 4263bfa..b51d1a9 100644
--- a/JSImpl/src/main.cpp
+++ b/JSImpl/src/main.cpp
@@ -1,12 +1,11 @@
#include "Lexer.h"
#include "Parser.h"
+#include "ASTPrinter.h"
#include <iostream>
#define LOG(msg) std::cout << msg << std::endl
#define EXECUTE_TEST(test) std::cout << #test << " "; test();
#define CHECK(cond) if (cond) {LOG("PASS");} else {LOG(#cond " FAIL");}
-#define CHECK(cond) cond ? LOG("PASS") : LOG("FAIL")
-
// Lexer Tests
void TestLess()
{
@@ -23,13 +22,13 @@ void TestNumber()
void TestNumberStartWithNine()
{
auto tokens = Tokenize("999");
- CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 999)
+ CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 999);
}
void TestNumberStartWithZero()
{
auto tokens = Tokenize("0999");
- CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 999)
+ CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 999);
}
void TestSpaceNewLineSpace()
@@ -73,25 +72,27 @@ void TestVariableDeclaration()
void TestParseUnaryExpr()
{
// TODO make actual test :D
- auto expr = Parse(Tokenize("function pesho() { var a = 0; return a; }"));
+ auto expr = Parse(Tokenize("function pesho(v1) { var a = 0; return a; }"));
+ ASTPrinter p(std::cout);
+ expr->Accept(p);
}
int main()
{
- EXECUTE_TEST(TestLess);
- EXECUTE_TEST(TestNumber);
- EXECUTE_TEST(TestNumberStartWithNine);
- EXECUTE_TEST(TestNumberStartWithZero);
- EXECUTE_TEST(TestString);
- EXECUTE_TEST(TestSpaceNewLineSpace);
- EXECUTE_TEST(TestStringSingleQuotedStrings);
- EXECUTE_TEST(TestKeyWord);
- EXECUTE_TEST(TestVariableDeclaration);
+ //EXECUTE_TEST(TestLess);
+ //EXECUTE_TEST(TestNumber);
+ //EXECUTE_TEST(TestNumberStartWithNine);
+ //EXECUTE_TEST(TestNumberStartWithZero);
+ //EXECUTE_TEST(TestString);
+ //EXECUTE_TEST(TestSpaceNewLineSpace);
+ //EXECUTE_TEST(TestStringSingleQuotedStrings);
+ //EXECUTE_TEST(TestKeyWord);
+ //EXECUTE_TEST(TestVariableDeclaration);
- //EXECUTE_TEST(TestParseUnaryExpr);
+ EXECUTE_TEST(TestParseUnaryExpr);
#if defined(_WIN32)
- std::system("pause");
+ //std::system("pause");
#endif
return 0;
}