Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / src / main.cpp
diff options
context:
space:
mode:
Commita2c53c44ff31d40030d45f9ce346413cd8fb815e (patch)
Author
 dtrendafilov <trendafilov.dn@gmail.com>
2018-11-15 19:22:41 +0200
Committer
 GitHub <noreply@github.com>
2018-11-15 19:22:41 +0200
Files914a9276c101d8d3e4ae100cffc216e06955a195 /JSImpl/src/main.cpp
IPL-a2c53c44ff31d40030d45f9ce346413cd8fb815e.tar
IPL-a2c53c44ff31d40030d45f9ce346413cd8fb815e.tar.gz
IPL-a2c53c44ff31d40030d45f9ce346413cd8fb815e.zip
Parentc32eda4e697803824e79878c74d541b81fbd04d8 (diff)
Parent255202e4096048ae72766522f7894830de10bd2f (diff)
Merge pull request #49 from SofiaCPP/code-gen
Code gen
1 files changed, 12 insertions, 2 deletions
-rw-r--r--JSImpl/src/main.cpp14
diff --git a/JSImpl/src/main.cpp b/JSImpl/src/main.cpp
index a10e4d1..c15458e 100644
--- a/JSImpl/src/main.cpp
+++ b/JSImpl/src/main.cpp
@@ -2,6 +2,7 @@
#include "Parser.h"
#include "ASTPrinter.h"
#include "ASTInterpreter.h"
+#include "ByteCodeGenerator.h"
#include <iostream>
#include <cstring>
@@ -62,11 +63,20 @@ void InteractiveInterpreter()
} while (true);
}
+void Generate()
+{
+ IPLVector<Token> tokens;
+ //Tokenize("var a = 0; var b = a + 123;a+b;", tokens);
+ /*Tokenize("var a; if(a < 4) { a = 8; if(a < 7) {var b = 4;}} else { a = 2} ", tokens);*/
+ Tokenize("var i = 0; for (var j = 0; j < 10; j = j + 1) { i = i + j; }", tokens);
+ std::cout << GenerateByteCode(Parse(tokens));
+}
+
int main()
{
//RunParseCalc();
- InteractiveInterpreter();
-
+ //InteractiveInterpreter();
+ Generate();
#if defined(_WIN32)
std::system("pause");
#endif